fixed line numbers when replacing nested access

master
Egor Ushakov 7 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; package org.jetbrains.java.decompiler.main.rels;
import org.jetbrains.java.decompiler.code.CodeConstants; import org.jetbrains.java.decompiler.code.CodeConstants;
@ -394,6 +394,11 @@ public class NestedMemberAccess {
ret.replaceExprent(ret.getRight(), invexpr.getLstParameters().get(1)); ret.replaceExprent(ret.getRight(), invexpr.getLstParameters().get(1));
fexpr.replaceExprent(fexpr.getInstance(), invexpr.getLstParameters().get(0)); fexpr.replaceExprent(fexpr.getInstance(), invexpr.getLstParameters().get(0));
} }
// do not use copied bytecodes
ret.getLeft().bytecode = null;
ret.getRight().bytecode = null;
retexprent = ret; retexprent = ret;
break; break;
case FUNCTION: case FUNCTION:
@ -421,6 +426,10 @@ public class NestedMemberAccess {
if (retexprent != null) { if (retexprent != null) {
// preserve original bytecodes
retexprent.bytecode = null;
retexprent.addBytecodeOffsets(invexpr.bytecode);
// hide synthetic access method // hide synthetic access method
boolean hide = true; boolean hide = true;

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

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

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

Loading…
Cancel
Save