IDEA-138578 Debugger spuriously jumps to decompiled method signature

master
Egor.Ushakov 10 years ago
parent 262d580ccc
commit 44ba5816f2
  1. 24
      src/org/jetbrains/java/decompiler/main/TextBuffer.java
  2. 2
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/IfExprent.java
  3. BIN
      testData/classes/pkg/TestClassLoop.class
  4. 4
      testData/results/TestClassLambda.dec
  5. 88
      testData/results/TestClassLoop.dec
  6. 1
      testData/results/TestClassTypes.dec
  7. 6
      testData/results/TestClassVar.dec
  8. 2
      testData/results/TestTryCatchFinally.dec
  9. 33
      testData/src/pkg/TestClassLoop.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2000-2014 JetBrains s.r.o. * Copyright 2000-2015 JetBrains s.r.o.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -150,9 +150,12 @@ public class TextBuffer {
while ((lineEnd = myStringBuilder.indexOf(myLineSeparator, lineStart)) > 0) { while ((lineEnd = myStringBuilder.indexOf(myLineSeparator, lineStart)) > 0) {
++count; ++count;
sb.append(myStringBuilder.substring(lineStart, lineEnd)); sb.append(myStringBuilder.substring(lineStart, lineEnd));
Integer integer = myLineMapping.get(count); Set<Integer> integers = myLineMapping.get(count);
if (integer != null) { if (integers != null) {
sb.append("// ").append(integer); sb.append("//");
for (Integer integer : integers) {
sb.append(' ').append(integer);
}
} }
sb.append(myLineSeparator); sb.append(myLineSeparator);
lineStart = lineEnd + length; lineStart = lineEnd + length;
@ -302,17 +305,18 @@ public class TextBuffer {
return myStringBuilder; return myStringBuilder;
} }
private Map<Integer, Integer> myLineMapping = null; // new to original private Map<Integer, Set<Integer>> myLineMapping = null; // new to original
public void dumpOriginalLineNumbers(int[] lineMapping) { public void dumpOriginalLineNumbers(int[] lineMapping) {
if (lineMapping.length > 0) { if (lineMapping.length > 0) {
myLineMapping = new HashMap<Integer, Integer>(); myLineMapping = new HashMap<Integer, Set<Integer>>();
for (int i = 0; i < lineMapping.length; i+=2) { for (int i = 0; i < lineMapping.length; i+=2) {
int key = lineMapping[i + 1]; int key = lineMapping[i + 1];
int value = lineMapping[i]; Set<Integer> existing = myLineMapping.get(key);
Integer existing = myLineMapping.get(key); if (existing == null) {
if (existing == null || value < existing) { existing = new TreeSet<Integer>();
myLineMapping.put(key, value); myLineMapping.put(key, existing);
} }
existing.add(lineMapping[i]);
} }
} }
} }

@ -89,7 +89,7 @@ public class IfExprent extends Exprent {
condition = stack.pop(); condition = stack.pop();
} }
else { else {
condition = new FunctionExprent(FUNC_TYPES[ifType], stack, null); condition = new FunctionExprent(FUNC_TYPES[ifType], stack, bytecodeOffsets);
} }
} }

@ -84,7 +84,7 @@ public class TestClassLambda {
System.out.println("hello2" + var1); System.out.println("hello2" + var1);
};// 87 };// 87
System.out.println("hello1" + var1);// 88 System.out.println("hello1" + var1);// 88
};// 86 };// 86 89
}// 90 }// 90
} }
@ -180,7 +180,9 @@ class 'pkg/TestClassLambda' {
method 'lambda$testLambda6$4 (IILjava/lang/String;)Z' { method 'lambda$testLambda6$4 (IILjava/lang/String;)Z' {
2 59 2 59
5 59
9 59 9 59
d 59
15 59 15 59
} }

@ -40,6 +40,39 @@ public class TestClassLoop {
System.out.println("4");// 58 System.out.println("4");// 58
} }
} }
public static int testWhileCombined(String var0) {
int var1 = var0.length();// 63
int var2 = 0;// 64
boolean var3 = false;// 65
boolean var4 = false;// 66
int var5 = 0;// 67
int var7 = 0;// 69
for(boolean var8 = false; var2 < var1; ++var2) {// 70 73 90
char var6 = var0.charAt(var2);// 74
if(var6 == 48) {// 75
++var7;// 76
} else {
if(var6 != 46) {// 77
break;
}
if(var3) {// 78
throw new NumberFormatException("multiple points");// 80
}
var5 = var2;// 82
if(var4) {// 83
var5 = var2 - 1;// 84
}
var3 = true;// 86
}
}
return var5;// 92
}
} }
class 'pkg/TestClassLoop' { class 'pkg/TestClassLoop' {
@ -77,6 +110,41 @@ class 'pkg/TestClassLoop' {
3a 39 3a 39
3c 39 3c 39
} }
method 'testWhileCombined (Ljava/lang/String;)I' {
1 44
4 44
5 45
6 45
7 46
8 46
9 47
a 47
c 48
d 48
f 49
10 49
12 51
13 51
17 51
1c 52
1f 52
23 53
25 53
28 54
30 56
32 56
36 60
3d 61
42 61
44 64
48 65
4b 66
4e 69
4f 69
50 51
58 73
}
} }
Lines mapping: Lines mapping:
@ -91,5 +159,25 @@ Lines mapping:
53 <-> 34 53 <-> 34
54 <-> 35 54 <-> 35
58 <-> 40 58 <-> 40
63 <-> 45
64 <-> 46
65 <-> 47
66 <-> 48
67 <-> 49
69 <-> 50
70 <-> 52
73 <-> 52
74 <-> 53
75 <-> 54
76 <-> 55
77 <-> 57
78 <-> 61
80 <-> 62
82 <-> 65
83 <-> 66
84 <-> 67
86 <-> 70
90 <-> 52
92 <-> 74
Not mapped: Not mapped:
39 39

@ -79,6 +79,7 @@ class 'pkg/TestClassTypes' {
1 22 1 22
2 22 2 22
3 22 3 22
4 22
c 22 c 22
} }

@ -27,7 +27,7 @@ public class TestClassVar {
while(var1 < 10) {// 47 while(var1 < 10) {// 47
int var2; int var2;
for(var2 = var1; var1 < 10 && var1 == 0; ++var1) {// 49 for(var2 = var1; var1 < 10 && var1 == 0; ++var1) {// 49 51
; ;
} }
@ -44,6 +44,7 @@ class 'pkg/TestClassVar' {
0 7 0 7
1 7 1 7
3 7 3 7
5 7
8 9 8 9
b 9 b 9
1f 11 1f 11
@ -65,8 +66,11 @@ class 'pkg/TestClassVar' {
0 25 0 25
1 25 1 25
3 27 3 27
5 27
9 29 9 29
b 29 b 29
d 29
11 29
14 29 14 29
1c 33 1c 33
1f 34 1f 34

@ -36,7 +36,7 @@ public class TestTryCatchFinally {
System.out.println("Finally");// 55 System.out.println("Finally");// 55
} }
return -1;// 56 return -1;// 56 57
} }
} }

@ -58,4 +58,37 @@ public class TestClassLoop {
System.out.println("4"); System.out.println("4");
} }
} }
public static int testWhileCombined(String in) {
int len = in.length();
int i = 0;
boolean decSeen = false;
boolean signSeen = false;
int decPt = 0;
char c;
int nLeadZero = 0;
int nTrailZero= 0;
skipLeadingZerosLoop:
while (i < len) {
c = in.charAt(i);
if (c == '0') {
nLeadZero++;
} else if (c == '.') {
if (decSeen) {
// already saw one ., this is the 2nd.
throw new NumberFormatException("multiple points");
}
decPt = i;
if (signSeen) {
decPt -= 1;
}
decSeen = true;
} else {
break skipLeadingZerosLoop;
}
i++;
}
return decPt;
}
} }

Loading…
Cancel
Save