Skip to content

Commit 27f72fb

Browse files
authored
Fix generic return type lambda breakpoint issue. Fix #1359 (#499)
* Fix generic return type lambda breakpoint issue. Fix #1359 The fix tries to compare the runtime lambda method signature with none generic version of the method signature found from AST traversal as a additional comparison to what is there.
1 parent 39046b7 commit 27f72fb

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/Breakpoint.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ private Location findMethodLocaiton(ReferenceType refType, String methodName, St
325325
for (Method method : methods) {
326326
if (!method.isAbstract() && !method.isNative()
327327
&& methodName.equals(method.name())
328-
&& (methodSiguature.equals(method.genericSignature()) || methodSiguature.equals(method.signature()))) {
328+
&& (methodSiguature.equals(method.genericSignature()) || methodSiguature.equals(method.signature())
329+
|| toNoneGeneric(methodSiguature).equals(method.signature()))) {
329330
location = method.location();
330331
break;
331332
}
@@ -334,6 +335,28 @@ private Location findMethodLocaiton(ReferenceType refType, String methodName, St
334335
return location;
335336
}
336337

338+
static String toNoneGeneric(String genericSig) {
339+
StringBuilder builder = new StringBuilder();
340+
boolean append = true;
341+
int depth = 0;
342+
char[] chars = genericSig.toCharArray();
343+
for (int i = 0; i < chars.length; i++) {
344+
char c = chars[i];
345+
if (c == '<') {
346+
depth++;
347+
append = (depth == 0);
348+
}
349+
if (append) {
350+
builder.append(c);
351+
}
352+
if (c == '>') {
353+
depth--;
354+
append = (depth == 0);
355+
}
356+
}
357+
return builder.toString();
358+
}
359+
337360
private List<Location> findLocaitonsOfLine(Method method, int lineNumber) {
338361
try {
339362
return method.locationsOfLine(lineNumber);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.microsoft.java.debug.core;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import org.junit.Test;
6+
7+
public class BreakpointTest {
8+
@Test
9+
public void testToNoneGeneric() {
10+
assertEquals("Ljava.util.List;", Breakpoint.toNoneGeneric("Ljava.util.List<java.lang.String;>;"));
11+
assertEquals("(Ljava/util/Map;)Ljava/util/Map;", Breakpoint.toNoneGeneric(
12+
"(Ljava/util/Map<Ljava/lang/String;Ljava/util/List<Ljava/lang/Integer;>;>;)Ljava/util/Map<Ljava/lang/String;Ljava/util/List<Ljava/lang/Integer;>;>;"));
13+
assertEquals("(Ljava/util/Map;)Ljava/util/Map;",
14+
Breakpoint.toNoneGeneric(
15+
"(Ljava/util/Map<Ljava/util/List<Ljava/lang/Integer;>;Ljava/util/List<Ljava/lang/Integer;>;>;)Ljava/util/Map<Ljava/util/List<Ljava/lang/Integer;>;Ljava/util/List<Ljava/lang/Integer;>;>;"));
16+
}
17+
}

0 commit comments

Comments
 (0)