decompiler: fixed anonymous class line numbers

master
Egor.Ushakov 10 years ago
parent 0bba28eded
commit a74f586e34
  1. 12
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/NewExprent.java
  2. BIN
      testData/classes/pkg/TestAnonymousClass$5.class
  3. BIN
      testData/classes/pkg/TestAnonymousClass$6.class
  4. BIN
      testData/classes/pkg/TestAnonymousClass$7.class
  5. BIN
      testData/classes/pkg/TestAnonymousClass$8.class
  6. BIN
      testData/classes/pkg/TestAnonymousClass$Inner.class
  7. BIN
      testData/classes/pkg/TestAnonymousClass$InnerRecursive.class
  8. BIN
      testData/classes/pkg/TestAnonymousClass.class
  9. 128
      testData/results/TestAnonymousClass.dec
  10. 41
      testData/src/pkg/TestAnonymousClass.java

@ -252,12 +252,16 @@ public class NewExprent extends Exprent {
buf.setLength(0); // remove the usual 'new <class>()', it will be replaced with lambda style '() ->' buf.setLength(0); // remove the usual 'new <class>()', it will be replaced with lambda style '() ->'
} }
Exprent methodObject = constructor == null ? null : constructor.getInstance(); Exprent methodObject = constructor == null ? null : constructor.getInstance();
new ClassWriter().classLambdaToJava(child, buf, methodObject, indent); TextBuffer clsBuf = new TextBuffer();
tracer.incrementCurrentSourceLine(buf.countLines()); new ClassWriter().classLambdaToJava(child, clsBuf, methodObject, indent);
buf.append(clsBuf);
tracer.incrementCurrentSourceLine(clsBuf.countLines());
} }
else { else {
new ClassWriter().classToJava(child, buf, indent, tracer); TextBuffer clsBuf = new TextBuffer();
tracer.incrementCurrentSourceLine(buf.countLines()); new ClassWriter().classToJava(child, clsBuf, indent, tracer);
buf.append(clsBuf);
tracer.incrementCurrentSourceLine(clsBuf.countLines());
} }
} }
else if (directArrayInit) { else if (directArrayInit) {

@ -19,6 +19,30 @@ public abstract class TestAnonymousClass {
boolean var2 = true;// 54 boolean var2 = true;// 54
} }
}; };
private final TestAnonymousClass.InnerRecursive y = new TestAnonymousClass.InnerRecursive(new TestAnonymousClass.InnerRecursive((TestAnonymousClass.InnerRecursive)null) {
void foo() {
boolean var1 = true;// 75
boolean var2 = true;// 76
boolean var3 = true;// 77
}
}) {
int v = 5;
int t = 5;
int j = 5;
int o = 5;
};
private final TestAnonymousClass.InnerRecursive x = new TestAnonymousClass.InnerRecursive(new TestAnonymousClass.InnerRecursive((TestAnonymousClass.InnerRecursive)null) {
void foo() {
boolean var1 = true;// 90
boolean var2 = true;// 91
boolean var3 = true;// 92
}
}) {
int v = 5;
int t = 5;
int j = 5;
int o = 5;
};
void foo(int var1) throws Exception { void foo(int var1) throws Exception {
if(var1 > 0) {// 10 if(var1 > 0) {// 10
@ -43,8 +67,19 @@ public abstract class TestAnonymousClass {
boolean var1 = true;// 39 boolean var1 = true;// 39
} }
static class InnerRecursive {
TestAnonymousClass.InnerRecursive r;
public InnerRecursive(TestAnonymousClass.InnerRecursive var1) {
this.r = var1;// 105
}
void foo() {
}
}
private static class Inner { private static class Inner {
private static final Runnable R_I = new Runnable() { private static Runnable R_I = new Runnable() {
public void run() { public void run() {
boolean var1 = true;// 66 boolean var1 = true;// 66
boolean var2 = true;// 67 boolean var2 = true;// 67
@ -84,59 +119,94 @@ class 'pkg/TestAnonymousClass$4' {
} }
} }
class 'pkg/TestAnonymousClass$5' {
method 'foo ()V' {
0 23
1 23
2 24
3 24
4 25
5 25
}
}
class 'pkg/TestAnonymousClass$7' {
method 'foo ()V' {
0 35
1 35
2 36
3 36
4 37
5 37
}
}
class 'pkg/TestAnonymousClass$1' { class 'pkg/TestAnonymousClass$1' {
method 'foo ()V' { method 'foo ()V' {
0 26 0 50
1 26 1 50
2 27 2 51
3 27 3 51
} }
} }
class 'pkg/TestAnonymousClass' { class 'pkg/TestAnonymousClass' {
method 'foo (I)V' { method 'foo (I)V' {
1 23 1 47
c 29 c 53
e 30 e 54
16 32 16 56
19 32 19 56
1a 32 1a 56
} }
method 'boo ()V' { method 'boo ()V' {
0 38 0 62
1 38 1 62
} }
method 'zoo ()V' { method 'zoo ()V' {
0 42 0 66
1 42 1 66
}
}
class 'pkg/TestAnonymousClass$InnerRecursive' {
method '<init> (Lpkg/TestAnonymousClass$InnerRecursive;)V' {
6 73
} }
} }
class 'pkg/TestAnonymousClass$Inner$1' { class 'pkg/TestAnonymousClass$Inner$1' {
method 'run ()V' { method 'run ()V' {
0 48 0 83
1 48 1 83
2 49 2 84
3 49 3 84
} }
} }
Lines mapping: Lines mapping:
10 <-> 24 10 <-> 48
11 <-> 30 11 <-> 54
13 <-> 27 13 <-> 51
14 <-> 28 14 <-> 52
17 <-> 31 17 <-> 55
21 <-> 33 21 <-> 57
28 <-> 6 28 <-> 6
29 <-> 7 29 <-> 7
35 <-> 39 35 <-> 63
39 <-> 43 39 <-> 67
45 <-> 12 45 <-> 12
46 <-> 13 46 <-> 13
53 <-> 18 53 <-> 18
54 <-> 19 54 <-> 19
66 <-> 49 66 <-> 84
67 <-> 50 67 <-> 85
75 <-> 24
76 <-> 25
77 <-> 26
90 <-> 36
91 <-> 37
92 <-> 38
105 <-> 74

@ -68,4 +68,45 @@ public abstract class TestAnonymousClass {
} }
}; };
} }
private final InnerRecursive y = new InnerRecursive(new InnerRecursive(null) {
@Override
void foo() {
int a =5;
int b =5;
int g =5;
}
}) {
int v =5;
int t =5;
int j =5;
int o =5;
};
private final InnerRecursive x = new InnerRecursive(new InnerRecursive(null) {
@Override
void foo() {
int a =5;
int b =5;
int g =5;
}
}) {
int v =5;
int t =5;
int j =5;
int o =5;
};
static class InnerRecursive {
InnerRecursive r;
public InnerRecursive(InnerRecursive r) {
this.r = r;
}
void foo() {
}
}
} }

Loading…
Cancel
Save