decompiler: fixed incorrect line mapping after abstract and native methods

master
Egor.Ushakov 10 years ago
parent 472f68f18a
commit 4a6a658b4c
  1. 1
      src/org/jetbrains/java/decompiler/main/ClassWriter.java
  2. 2
      test/org/jetbrains/java/decompiler/BytecodeToSourceMappingTest.java
  3. BIN
      testData/classes/pkg/TestAbstractMethods.class
  4. 30
      testData/results/TestAbstractMethods.dec
  5. 26
      testData/results/TestClassSimpleBytecodeMapping.dec
  6. 6
      testData/results/TestSynchronizedMapping.dec
  7. 19
      testData/src/pkg/TestAbstractMethods.java

@ -782,6 +782,7 @@ public class ClassWriter {
buffer.append(';');
buffer.appendLineSeparator();
tracer.incrementCurrentSourceLine();
}
else {
if (!clinit && !dinit) {

@ -26,9 +26,11 @@ public class BytecodeToSourceMappingTest extends SingleClassesTestBase {
protected Map<String, Object> getDecompilerOptions() {
return new HashMap<String, Object>() {{
put(IFernflowerPreferences.BYTECODE_SOURCE_MAPPING, "1");
put(IFernflowerPreferences.DUMP_ORIGINAL_LINES, "1");
}};
}
@Test public void testSimpleBytecodeMapping() { doTest("pkg/TestClassSimpleBytecodeMapping"); }
@Test public void testSynchronizedMapping() { doTest("pkg/TestSynchronizedMapping"); }
@Test public void testAbstractMethods() { doTest("pkg/TestAbstractMethods"); }
}

@ -0,0 +1,30 @@
package pkg;
public abstract class TestAbstractMethods {
public abstract void foo();
public int test(int var1) {
return var1;// 11
}
protected abstract void foo1();
public void test2(String var1) {
System.out.println(var1);// 17
}
}
class 'pkg/TestAbstractMethods' {
method 'test (I)I' {
1 6
}
method 'test2 (Ljava/lang/String;)V' {
0 12
4 12
}
}
Lines mapping:
11 <-> 7
17 <-> 13

@ -2,25 +2,25 @@ package pkg;
public class TestClassSimpleBytecodeMapping {
public int test() {
System.out.println("before");
this.run(new Runnable() {
System.out.println("before");// 12
this.run(new Runnable() {// 14
public void run() {
System.out.println("Runnable");
System.out.println("Runnable");// 17
}
});
this.test2("1");
if(Math.random() > 0.0D) {
System.out.println("0");
return 0;
this.test2("1");// 21
if(Math.random() > 0.0D) {// 23
System.out.println("0");// 24
return 0;// 25
} else {
System.out.println("1");
return 1;
System.out.println("1");// 27
return 1;// 28
}
}
public void test2(String var1) {
try {
Integer.parseInt(var1);
Integer.parseInt(var1);// 34
} catch (Exception var6) {
System.out.println(var6);
} finally {
@ -30,18 +30,18 @@ public class TestClassSimpleBytecodeMapping {
}
void run(Runnable var1) {
var1.run();
var1.run();// 49
}
public class InnerClass2 {
public void print() {
System.out.println("Inner2");
System.out.println("Inner2");// 54
}
}
public class InnerClass {
public void print() {
System.out.println("Inner");
System.out.println("Inner");// 44
}
}
}

@ -2,13 +2,13 @@ package pkg;
public class TestSynchronizedMapping {
public int test(int var1) {
synchronized(this) {
return var1++;
synchronized(this) {// 8
return var1++;// 9
}
}
public void test2(String var1) {
System.out.println(var1);
System.out.println(var1);// 14
}
}

@ -0,0 +1,19 @@
package pkg;
import java.lang.Override;
import java.lang.Runnable;
public abstract class TestAbstractMethods {
public abstract void foo();
public int test(int a) {
return a;
}
protected abstract void foo1();
public void test2(String a) {
System.out.println(a);
}
}
Loading…
Cancel
Save