Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generic return type lambda breakpoint issue. Fix #1359 #499

Merged
merged 6 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ private Location findMethodLocaiton(ReferenceType refType, String methodName, St
for (Method method : methods) {
if (!method.isAbstract() && !method.isNative()
&& methodName.equals(method.name())
&& (methodSiguature.equals(method.genericSignature()) || methodSiguature.equals(method.signature()))) {
&& (methodSiguature.equals(method.genericSignature()) || methodSiguature.equals(method.signature())
|| toNoneGeneric(methodSiguature).equals(method.signature()))) {
gayanper marked this conversation as resolved.
Show resolved Hide resolved
location = method.location();
break;
}
Expand All @@ -334,6 +335,28 @@ private Location findMethodLocaiton(ReferenceType refType, String methodName, St
return location;
}

static String toNoneGeneric(String genericSig) {
StringBuilder builder = new StringBuilder();
boolean append = true;
int depth = 0;
char[] chars = genericSig.toCharArray();
for (int i = 0; i < chars.length; i++) {
char c = chars[i];
if (c == '<') {
depth++;
append = (depth == 0);
}
if (append) {
builder.append(c);
}
if (c == '>') {
depth--;
append = (depth == 0);
}
}
return builder.toString();
}

private List<Location> findLocaitonsOfLine(Method method, int lineNumber) {
try {
return method.locationsOfLine(lineNumber);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.microsoft.java.debug.core;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class BreakpointTest {
@Test
public void testToNoneGeneric() {
assertEquals("Ljava.util.List;", Breakpoint.toNoneGeneric("Ljava.util.List<java.lang.String;>;"));
assertEquals("(Ljava/util/Map;)Ljava/util/Map;", Breakpoint.toNoneGeneric(
"(Ljava/util/Map<Ljava/lang/String;Ljava/util/List<Ljava/lang/Integer;>;>;)Ljava/util/Map<Ljava/lang/String;Ljava/util/List<Ljava/lang/Integer;>;>;"));
assertEquals("(Ljava/util/Map;)Ljava/util/Map;",
Breakpoint.toNoneGeneric(
"(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;>;>;"));
}
}
Loading