fixed line numbers when replacing nested access

master
Egor Ushakov 6 years ago
parent 4a790b1c7c
commit 7310e9e989
  1. 11
      src/org/jetbrains/java/decompiler/main/rels/NestedMemberAccess.java
  2. 18
      testData/results/TestAccessReplace.dec
  3. 10
      testData/results/TestClassFields.dec
  4. 22
      testData/results/TestSyntheticAccess.dec

@ -1,4 +1,4 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.java.decompiler.main.rels;
import org.jetbrains.java.decompiler.code.CodeConstants;
@ -394,6 +394,11 @@ public class NestedMemberAccess {
ret.replaceExprent(ret.getRight(), invexpr.getLstParameters().get(1));
fexpr.replaceExprent(fexpr.getInstance(), invexpr.getLstParameters().get(0));
}
// do not use copied bytecodes
ret.getLeft().bytecode = null;
ret.getRight().bytecode = null;
retexprent = ret;
break;
case FUNCTION:
@ -421,6 +426,10 @@ public class NestedMemberAccess {
if (retexprent != null) {
// preserve original bytecodes
retexprent.bytecode = null;
retexprent.addBytecodeOffsets(invexpr.bytecode);
// hide synthetic access method
boolean hide = true;

@ -15,8 +15,8 @@ public class TestAccessReplace {
public class Inner {
public Inner(String b) {
TestAccessReplace.fooS();// 25
TestAccessReplace.this.foo();
TestAccessReplace.fooS();// 26
TestAccessReplace.this.foo();// 27
TestAccessReplace.fooSParams(1L, 2L);// 28
TestAccessReplace.this.fooParams(1L, 2L);// 29
}// 30
@ -43,14 +43,14 @@ class 'pkg/TestAccessReplace' {
class 'pkg/TestAccessReplace$Inner' {
method '<init> (Lpkg/TestAccessReplace;Ljava/lang/String;)V' {
0 17
1 18
2 19
3 20
9 17
d 18
10 19
11 19
14 19
18 20
19 20
1c 20
1f 21
}
}
@ -60,10 +60,10 @@ Lines mapping:
20 <-> 8
21 <-> 11
22 <-> 14
25 <-> 18
26 <-> 18
27 <-> 19
28 <-> 20
29 <-> 21
30 <-> 22
Not mapped:
26
27
25

@ -8,7 +8,7 @@ public class TestClassFields {
static {
sizes = new int[names.length];// 15
TestClassFields.Inner.staticMutable = 3;// 17
SIZE = TestClassFields.Inner.staticMutable;// 14 18
SIZE = TestClassFields.Inner.staticMutable;// 18
}// 19
private static class Inner {
@ -18,20 +18,20 @@ public class TestClassFields {
class 'pkg/TestClassFields' {
method '<clinit> ()V' {
0 10
2 9
11 8
14 8
17 8
1a 9
1b 9
1f 10
22 10
25 11
}
}
Lines mapping:
14 <-> 11
15 <-> 9
17 <-> 10
18 <-> 11
19 <-> 12
Not mapped:
14

@ -28,8 +28,8 @@ class TestSyntheticAccess {
}// 19
void incrementS() {
++TestSyntheticAccess.s;// 22 23
}
++TestSyntheticAccess.s;// 22
}// 23
void decrementS() {
TestSyntheticAccess.s--;// 26
@ -39,46 +39,44 @@ class TestSyntheticAccess {
class 'pkg/TestSyntheticAccess$Assigner' {
method 'assignI (I)V' {
3 8
5 8
9 9
}
method 'assignS (I)V' {
2 12
1 12
5 13
}
}
class 'pkg/TestSyntheticAccess$Incrementer' {
method 'orI ()V' {
1 18
3 18
8 18
b 18
c 18
d 18
11 19
}
method 'incrementI ()V' {
2 22
7 22
4 22
8 23
}
method 'decrementI ()V' {
2 26
6 26
4 26
8 27
}
method 'incrementS ()V' {
0 30
4 30
4 31
}
method 'decrementS ()V' {
0 34
4 35
5 34
}
}
@ -90,7 +88,7 @@ Lines mapping:
18 <-> 27
19 <-> 28
22 <-> 31
23 <-> 31
23 <-> 32
26 <-> 35
27 <-> 36
32 <-> 9

Loading…
Cancel
Save