mirror of
https://github.com/moparisthebest/fernflower
synced 2025-02-16 15:00:16 -05:00
decompiler: fixed line mapping for try-catch and nested classes
This commit is contained in:
parent
47fad13908
commit
0bcd7fba5c
@ -254,8 +254,11 @@ public class ClassWriter {
|
||||
|
||||
if (hasContent) {
|
||||
buffer.appendLineSeparator();
|
||||
startLine++;
|
||||
}
|
||||
classToJava(inner, buffer, indent + 1, tracer);
|
||||
BytecodeMappingTracer class_tracer = new BytecodeMappingTracer(startLine);
|
||||
classToJava(inner, buffer, indent + 1, class_tracer);
|
||||
startLine = buffer.countLines();
|
||||
|
||||
hasContent = true;
|
||||
}
|
||||
@ -840,7 +843,7 @@ public class ClassWriter {
|
||||
|
||||
// save total lines
|
||||
// TODO: optimize
|
||||
tracer.setCurrentSourceLine(buffer.countLines(start_index_method));
|
||||
//tracer.setCurrentSourceLine(buffer.countLines(start_index_method));
|
||||
|
||||
return !hideMethod;
|
||||
}
|
||||
|
@ -280,6 +280,7 @@ public class ClassesProcessor {
|
||||
}
|
||||
//buffer.append(lineSeparator);
|
||||
|
||||
total_offset_lines = buffer.countLines();
|
||||
buffer.append(classBuffer);
|
||||
|
||||
if (DecompilerContext.getOption(IFernflowerPreferences.BYTECODE_SOURCE_MAPPING)) {
|
||||
|
@ -187,7 +187,6 @@ public class CatchStatement extends Statement {
|
||||
tracer.incrementCurrentSourceLine();
|
||||
buf.append(ExprProcessor.jmpWrapper(stats.get(i), indent + 1, true, tracer)).append(indstr)
|
||||
.append("}");
|
||||
tracer.incrementCurrentSourceLine();
|
||||
}
|
||||
buf.append(new_line_separator);
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,6 +8,7 @@ public class TestClassSimpleBytecodeMapping {
|
||||
System.out.println("Runnable");
|
||||
}
|
||||
});
|
||||
this.test2("1");
|
||||
if(Math.random() > 0.0D) {
|
||||
System.out.println("0");
|
||||
return 0;
|
||||
@ -17,9 +18,30 @@ public class TestClassSimpleBytecodeMapping {
|
||||
}
|
||||
}
|
||||
|
||||
public void test2(String var1) {
|
||||
try {
|
||||
Integer.parseInt(var1);
|
||||
} catch (Exception var3) {
|
||||
System.out.println(var3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void run(Runnable var1) {
|
||||
var1.run();
|
||||
}
|
||||
|
||||
public class InnerClass2 {
|
||||
public void print() {
|
||||
System.out.println("Inner2");
|
||||
}
|
||||
}
|
||||
|
||||
public class InnerClass {
|
||||
public void print() {
|
||||
System.out.println("Inner");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class 'pkg/TestClassSimpleBytecodeMapping$1' {
|
||||
@ -36,24 +58,46 @@ class 'pkg/TestClassSimpleBytecodeMapping' {
|
||||
3 4
|
||||
5 4
|
||||
11 5
|
||||
14 10
|
||||
15 10
|
||||
17 10
|
||||
18 10
|
||||
19 10
|
||||
1c 11
|
||||
1a 11
|
||||
1d 11
|
||||
1e 11
|
||||
1f 11
|
||||
21 11
|
||||
24 12
|
||||
22 12
|
||||
25 12
|
||||
26 14
|
||||
29 14
|
||||
2b 14
|
||||
2e 15
|
||||
27 12
|
||||
2a 13
|
||||
2b 13
|
||||
2c 15
|
||||
2f 15
|
||||
31 15
|
||||
34 16
|
||||
35 16
|
||||
}
|
||||
|
||||
method 'test2 (Ljava/lang/String;)V' {
|
||||
1 22
|
||||
}
|
||||
|
||||
method 'run (Ljava/lang/Runnable;)V' {
|
||||
1 20
|
||||
1 30
|
||||
}
|
||||
}
|
||||
|
||||
class 'pkg/TestClassSimpleBytecodeMapping$InnerClass2' {
|
||||
method 'print ()V' {
|
||||
0 35
|
||||
3 35
|
||||
5 35
|
||||
}
|
||||
}
|
||||
|
||||
class 'pkg/TestClassSimpleBytecodeMapping$InnerClass' {
|
||||
method 'print ()V' {
|
||||
0 41
|
||||
3 41
|
||||
5 41
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,8 +106,12 @@ Lines mapping:
|
||||
14 <-> 6
|
||||
17 <-> 8
|
||||
21 <-> 11
|
||||
22 <-> 12
|
||||
23 <-> 13
|
||||
25 <-> 15
|
||||
26 <-> 16
|
||||
31 <-> 21
|
||||
23 <-> 12
|
||||
24 <-> 13
|
||||
25 <-> 14
|
||||
27 <-> 16
|
||||
28 <-> 17
|
||||
34 <-> 23
|
||||
42 <-> 42
|
||||
47 <-> 31
|
||||
52 <-> 36
|
||||
|
@ -18,6 +18,8 @@ public class TestClassSimpleBytecodeMapping {
|
||||
}
|
||||
});
|
||||
|
||||
test2("1");
|
||||
|
||||
if(Math.random() > 0) {
|
||||
System.out.println("0");
|
||||
return 0;
|
||||
@ -27,7 +29,27 @@ public class TestClassSimpleBytecodeMapping {
|
||||
}
|
||||
}
|
||||
|
||||
public void test2(String a) {
|
||||
try {
|
||||
Integer.parseInt(a);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
}
|
||||
|
||||
public class InnerClass {
|
||||
public void print() {
|
||||
System.out.println("Inner");
|
||||
}
|
||||
}
|
||||
|
||||
void run(Runnable r) {
|
||||
r.run();
|
||||
}
|
||||
|
||||
public class InnerClass2 {
|
||||
public void print() {
|
||||
System.out.println("Inner2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user