0

In bug prediction research topic, you need to compare version (N) from your code (Buggy code) with version (N+1) i.e (Fixed code) in order to get exact code changes and more over to normalise and anonymise these code changes to get bug fix-patterns

http://scg.unibe.ch/archive/papers/Osma14aMiningBugFixChanges.pdf https://pdfs.semanticscholar.org/80c0/a9509068c9073f5b510d145c6fe4dc548afe.pdf

I've tried comparing the two files and get lines numbers of difference using : Java.io.LineNumberReader.getLineNumber() Method

but still I couldn't find a way to achieve the following form :

(( View ) getParent (1) ). invalidate () ---> View parent = ( View ) getParent (1) ;
if ( parent != null ) parent . invalidate ();

the previous extracted "Bug Hunk" and "Fix Hunk" then should be transformed into:

(( T0)T1(N)).T2 () ---> T0T3 =( T0)T1(N);
if(T3 != null )T3.T2 ();

I've considered using "JAVA parser" but it was a dead end!

Please Advice!

Sailendra
  • 1,318
  • 14
  • 29
Y-K
  • 1
  • 1
  • consider "(( View ) getParent (1) ). invalidate ()" some random line in your java code then it must be transformed to the form : (( T0)T1(N)).T2 () ---> T0T3 =( T0)T1(N); if(T3 != null )T3.T2 (); where : (a) Every number is replaced by N. (b) Words are anonymized using numbered letters (T0, T1, T2, etc.). (c) Every white space is removed. – Y-K Dec 13 '19 at 22:56
  • I don't need to consider the semantics of an identifier, in fact the general approach uses JGit library for parsing the history changes in order to find bug-fix commits and then it uses the JAPA library for parsing the java code after all the comparison is narrowed down from method level to only changed lines in these two compared methods – Y-K Dec 14 '19 at 00:48
  • I'm working on a simpler approach that reads two java programs as text files and writes the different lines in a new file then normalizes and anonymizes this output file based on the previously mentioned steps – Y-K Dec 14 '19 at 00:54
  • We call the minimal code that had the bug a bug hunk, and we call the minimal code that fixed the bug a fix hunk, – Y-K Dec 14 '19 at 00:57
  • "Then you'd have to take a java compiler that maintains scopes and a symbol table and bend it to your purpose by writing your own back end" I really appreciate your advice but I don't have that much time to do such a thing – Y-K Dec 31 '19 at 00:47
  • I did found a library that could serve this particular purpose it's called "java-diff-utils" the zipped source code is available on git-hub but it misses documentation – Y-K Dec 31 '19 at 00:52

0 Answers0