Skip to content

Commit 13f26fe

Browse files
committed
Unable to set a conditional breakpoint in a method with a parameter
using generic extends X Fix #693
1 parent ad975c4 commit 13f26fe

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.ArrayList;
2+
import java.util.Arrays;
3+
import java.util.HashSet;
4+
import java.util.List;
5+
import java.util.Set;
6+
7+
public class Issue693 {
8+
static class Generic<U extends Number> {
9+
10+
private U u;
11+
12+
public Generic(U u) {
13+
this.u = u;
14+
}
15+
16+
void test(Generic<U> generic) {
17+
System.out.println("tested " + this);
18+
}
19+
}
20+
21+
public static void main(String[] args) {
22+
Generic<Integer> generic = new Generic<>(5);
23+
generic.test(generic);
24+
}
25+
}

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@
161161

162162
import com.sun.jdi.InternalException;
163163
import com.sun.jdi.InvocationException;
164-
165164
import junit.framework.TestCase;
166165

167166
/**
@@ -446,6 +445,7 @@ synchronized void assert17Project() {
446445
cfgs.add(createLaunchConfiguration(jp, "Bug567801"));
447446
cfgs.add(createLaunchConfiguration(jp, "Bug572782"));
448447
cfgs.add(createLaunchConfiguration(jp, "Bug576829"));
448+
cfgs.add(createLaunchConfiguration(jp, "Issue693"));
449449
loaded17 = true;
450450
waitForBuild();
451451
}

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/eval/GenericsEval17Test.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ public void testEvaluate_Bug576829_RecursiveMultipleGenerics_ObjectInstanceEvalu
141141
assertEquals("value is not false", "false", value.getValueString());
142142
}
143143

144+
public void testEvaluate_Issue693() throws Exception {
145+
createConditionalLineBreakpoint(17, "Issue693", "generic.u.intValue() == 5", true);
146+
javaThread = launchToBreakpoint("Issue693");
147+
assertNotNull("The program did not suspend", javaThread);
148+
149+
String snippet = "generic.u.intValue()";
150+
IValue value = doEval(javaThread, snippet);
151+
152+
assertNotNull("value is null", value);
153+
assertEquals("value is not 5", "5", value.getValueString());
154+
}
155+
144156
private void debugWithBreakpoint(String testClass, int lineNumber) throws Exception {
145157
createLineBreakpoint(lineNumber, testClass);
146158
javaThread = launchToBreakpoint(testClass);

org.eclipse.jdt.debug/eval/org/eclipse/jdt/internal/debug/eval/ast/engine/ASTEvaluationEngine.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,11 @@ private void scanAndFixSignature(String genericSignature, String erasureSignatur
392392
* and also generic signature such as Ljava/util/function/Predicate<+Ljava/util/List<Ljava/lang/Integer;>;>; Ljava/util/Comparator<-TT;>;
393393
* which will fail to properly resolved to the type.
394394
*/
395-
if (genericSignature.startsWith(String.valueOf(Signature.C_TYPE_VARIABLE)) || genericSignature.startsWith(String.valueOf(Signature.C_CAPTURE))
395+
if (genericSignature.startsWith(String.valueOf(Signature.C_TYPE_VARIABLE))) {
396+
fixedSignature.append(genericSignature.substring(String.valueOf(Signature.C_TYPE_VARIABLE).length(), genericSignature.length() - 1));
397+
return;
398+
}
399+
if (genericSignature.startsWith(String.valueOf(Signature.C_CAPTURE))
396400
|| genericSignature.startsWith(String.valueOf(Signature.C_SUPER))) {
397401
fixedSignature.append(toDotQualified(erasureSignature));
398402
return;

0 commit comments

Comments
 (0)