Skip to content

Commit 36c4b3b

Browse files
committed
Add line numbers to field declarations when feasible
1 parent f5160a4 commit 36c4b3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+842
-149
lines changed

src/org/jetbrains/java/decompiler/main/ClassWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,8 @@ private static boolean isSuperClassSealed(StructClass cl) {
783783
private void writeField(TextBuffer buffer, int indent, StructField fd, ClassWrapper wrapper) {
784784
TextBuffer fieldBuffer = new TextBuffer();
785785
writeField(wrapper, wrapper.getClassStruct(), fd, fieldBuffer, indent + 1);
786-
fieldBuffer.clearUnassignedBytecodeMappingData();
787-
buffer.append(fieldBuffer);
786+
String initializer = fd.hasModifier(CodeConstants.ACC_STATIC) ? "<clinit> ()V" : "<init> ()V";
787+
buffer.append(fieldBuffer, wrapper.getClassStruct().qualifiedName, initializer);
788788
}
789789

790790
public void writeField(ClassWrapper wrapper, StructClass cl, StructField fd, TextBuffer buffer, int indent) {

testData/results/pkg/TestAnonymousClass.dec

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public abstract class TestAnonymousClass {
2424
int b = 5;// 65
2525
}// 66
2626
};
27-
private final TestAnonymousClass.InnerRecursive y = new TestAnonymousClass.InnerRecursive(new TestAnonymousClass.InnerRecursive(null) {
27+
private final TestAnonymousClass.InnerRecursive y = new TestAnonymousClass.InnerRecursive(new TestAnonymousClass.InnerRecursive(null) {// 83
2828
@Override
2929
void foo() {
3030
int a = 5;// 86
@@ -37,7 +37,7 @@ public abstract class TestAnonymousClass {
3737
int j = 5;
3838
int o = 5;
3939
};
40-
private final TestAnonymousClass.InnerRecursive x = new TestAnonymousClass.InnerRecursive(new TestAnonymousClass.InnerRecursive(null) {
40+
private final TestAnonymousClass.InnerRecursive x = new TestAnonymousClass.InnerRecursive(new TestAnonymousClass.InnerRecursive(null) {// 98
4141
@Override
4242
void foo() {
4343
int a = 5;// 101
@@ -85,7 +85,7 @@ public abstract class TestAnonymousClass {
8585

8686
public static Iterable<Integer> innerInAnon() {
8787
return new Iterable<Integer>() {// 125
88-
public int field = 1491401;
88+
public int field = 1491401;// 126
8989

9090
@Override
9191
public Iterator<Integer> iterator() {
@@ -107,7 +107,7 @@ public abstract class TestAnonymousClass {
107107

108108
public static Iterable<Integer> innerInAnon2() {
109109
return new Iterable<Integer>() {// 149
110-
public int field = 1491401;
110+
public int field = 1491401;// 150
111111

112112
@Override
113113
public Iterator<Integer> iterator() {
@@ -185,31 +185,12 @@ class 'pkg/TestAnonymousClass$5' {
185185
}
186186
}
187187

188-
class 'pkg/TestAnonymousClass$6' {
189-
method 'foo ()V' {
190-
0 29
191-
1 29
192-
2 30
193-
3 30
194-
4 31
195-
5 31
196-
6 32
197-
}
198-
}
199-
200-
class 'pkg/TestAnonymousClass$8' {
201-
method 'foo ()V' {
202-
0 42
203-
1 42
204-
2 43
205-
3 43
206-
4 44
207-
5 44
208-
6 45
188+
class 'pkg/TestAnonymousClass' {
189+
method '<init> ()V' {
190+
f 26
191+
24 39
209192
}
210-
}
211193

212-
class 'pkg/TestAnonymousClass' {
213194
method 'foo (I)V' {
214195
0 54
215196
1 54
@@ -264,6 +245,30 @@ class 'pkg/TestAnonymousClass' {
264245
}
265246
}
266247

248+
class 'pkg/TestAnonymousClass$6' {
249+
method 'foo ()V' {
250+
0 29
251+
1 29
252+
2 30
253+
3 30
254+
4 31
255+
5 31
256+
6 32
257+
}
258+
}
259+
260+
class 'pkg/TestAnonymousClass$8' {
261+
method 'foo ()V' {
262+
0 42
263+
1 42
264+
2 43
265+
3 43
266+
4 44
267+
5 44
268+
6 45
269+
}
270+
}
271+
267272
class 'pkg/TestAnonymousClass$1' {
268273
method 'foo ()V' {
269274
0 58
@@ -288,6 +293,11 @@ class 'pkg/TestAnonymousClass$2' {
288293
}
289294

290295
class 'pkg/TestAnonymousClass$10' {
296+
method '<init> ()V' {
297+
5 87
298+
6 87
299+
}
300+
291301
method 'iterator ()Ljava/util/Iterator;' {
292302
8 91
293303
}
@@ -316,6 +326,11 @@ class 'pkg/TestAnonymousClass$10$Inner' {
316326
}
317327

318328
class 'pkg/TestAnonymousClass$11' {
329+
method '<init> ()V' {
330+
5 109
331+
6 109
332+
}
333+
319334
method 'iterator ()Ljava/util/Iterator;' {
320335
14 113
321336
}
@@ -399,10 +414,12 @@ Lines mapping:
399414
77 <-> 140
400415
78 <-> 141
401416
79 <-> 142
417+
83 <-> 27
402418
86 <-> 30
403419
87 <-> 31
404420
88 <-> 32
405421
89 <-> 33
422+
98 <-> 40
406423
101 <-> 43
407424
102 <-> 44
408425
103 <-> 45
@@ -411,13 +428,16 @@ Lines mapping:
411428
117 <-> 151
412429
121 <-> 154
413430
125 <-> 87
431+
126 <-> 88
414432
132 <-> 98
415433
137 <-> 102
416434
143 <-> 92
417435
149 <-> 109
436+
150 <-> 110
418437
157 <-> 121
419438
162 <-> 125
420439
169 <-> 114
421440
Not mapped:
441+
10
422442
21
423443
115
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
package pkg;
22

33
public class TestAnonymousParamNames {
4-
private final TestAnonymousParamNames.Clazz reference = new TestAnonymousParamNames.Clazz(0L, false) {};
4+
private final TestAnonymousParamNames.Clazz reference = new TestAnonymousParamNames.Clazz(0L, false) {};// 21
55

66
private class Clazz {
77
public Clazz(long paramL, boolean paramB) {
88
}// 25
99
}
1010
}
1111

12+
class 'pkg/TestAnonymousParamNames' {
13+
method '<init> ()V' {
14+
a 3
15+
b 3
16+
}
17+
}
18+
1219
class 'pkg/TestAnonymousParamNames$Clazz' {
1320
method '<init> (Lpkg/TestAnonymousParamNames;JZ)V' {
1421
9 7
1522
}
1623
}
1724

1825
Lines mapping:
26+
21 <-> 4
1927
25 <-> 8
2028
Not mapped:
29+
20
2130
24

testData/results/pkg/TestArrayFieldAccess.dec

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package pkg;
22

33
public class TestArrayFieldAccess {
4-
private int[] array = new int[10];
5-
private int index = 1;
4+
private int[] array = new int[10];// 4
5+
private int index = 1;// 5
66
private int value;
77

88
public void test() {
@@ -43,6 +43,12 @@ public class TestArrayFieldAccess {
4343
}
4444

4545
class 'pkg/TestArrayFieldAccess' {
46+
method '<init> ()V' {
47+
5 3
48+
6 3
49+
d 4
50+
}
51+
4652
method 'test ()V' {
4753
0 8
4854
1 8
@@ -225,6 +231,8 @@ class 'pkg/TestArrayFieldAccess' {
225231
}
226232

227233
Lines mapping:
234+
4 <-> 4
235+
5 <-> 5
228236
9 <-> 9
229237
10 <-> 10
230238
13 <-> 13
@@ -246,3 +254,5 @@ Lines mapping:
246254
43 <-> 39
247255
44 <-> 40
248256
46 <-> 42
257+
Not mapped:
258+
3

testData/results/pkg/TestArrayFieldAccess1.dec

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package pkg;
22

33
public class TestArrayFieldAccess1 {
4-
private int[] array = new int[10];
5-
private int index = 1;
4+
private int[] array = new int[10];// 4
5+
private int index = 1;// 5
66
private int value;
77

88
public void test() {
@@ -47,6 +47,12 @@ public class TestArrayFieldAccess1 {
4747
}
4848

4949
class 'pkg/TestArrayFieldAccess1' {
50+
method '<init> ()V' {
51+
5 3
52+
6 3
53+
d 4
54+
}
55+
5056
method 'test ()V' {
5157
0 8
5258
1 8
@@ -268,6 +274,8 @@ class 'pkg/TestArrayFieldAccess1' {
268274
}
269275

270276
Lines mapping:
277+
4 <-> 4
278+
5 <-> 5
271279
9 <-> 9
272280
10 <-> 10
273281
13 <-> 13
@@ -291,3 +299,5 @@ Lines mapping:
291299
46 <-> 42
292300
49 <-> 45
293301
50 <-> 46
302+
Not mapped:
303+
3

testData/results/pkg/TestArrayFieldAccess2.dec

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package pkg;
22

33
public class TestArrayFieldAccess2 {
4-
private int[] array = new int[10];
5-
private int index = 1;
4+
private int[] array = new int[10];// 4
5+
private int index = 1;// 5
66
private int value;
77

88
public void test() {
@@ -63,6 +63,12 @@ public class TestArrayFieldAccess2 {
6363
}
6464

6565
class 'pkg/TestArrayFieldAccess2' {
66+
method '<init> ()V' {
67+
5 3
68+
6 3
69+
d 4
70+
}
71+
6672
method 'test ()V' {
6773
0 8
6874
1 8
@@ -336,6 +342,8 @@ class 'pkg/TestArrayFieldAccess2' {
336342
}
337343

338344
Lines mapping:
345+
4 <-> 4
346+
5 <-> 5
339347
9 <-> 9
340348
10 <-> 10
341349
13 <-> 13
@@ -364,3 +372,5 @@ Lines mapping:
364372
58 <-> 58
365373
61 <-> 61
366374
62 <-> 62
375+
Not mapped:
376+
3

testData/results/pkg/TestArrays.dec

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package pkg;
22

33
public class TestArrays {
4-
private static final int[] array1 = new int[]{1, 2, 3, 4};
5-
private static int[] array2 = new int[]{2, 3, 4, 5};
6-
private int[] array3 = new int[]{3, 4, 5, 6};
4+
private static final int[] array1 = new int[]{1, 2, 3, 4};// 4
5+
private static int[] array2 = new int[]{2, 3, 4, 5};// 5
6+
private int[] array3 = new int[]{3, 4, 5, 6};// 6
77

88
void test() {
99
int a = this.array3[3];// 9
@@ -13,6 +13,25 @@ public class TestArrays {
1313
}
1414

1515
class 'pkg/TestArrays' {
16+
method '<clinit> ()V' {
17+
5 3
18+
9 3
19+
d 3
20+
11 3
21+
1b 4
22+
1f 4
23+
23 4
24+
27 4
25+
}
26+
27+
method '<init> ()V' {
28+
a 5
29+
e 5
30+
12 5
31+
16 5
32+
17 5
33+
}
34+
1635
method 'test ()V' {
1736
0 8
1837
1 8
@@ -40,7 +59,12 @@ class 'pkg/TestArrays' {
4059
}
4160

4261
Lines mapping:
62+
4 <-> 4
63+
5 <-> 5
64+
6 <-> 6
4365
9 <-> 9
4466
10 <-> 10
4567
11 <-> 11
4668
12 <-> 12
69+
Not mapped:
70+
3

0 commit comments

Comments
 (0)