Skip to content

Commit

Permalink
Merge branch 'main' into jinbo_lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
testforstephen authored Dec 12, 2023
2 parents 011b33c + 27f72fb commit c2a47bf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
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()))) {
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;>;>;"));
}
}

0 comments on commit c2a47bf

Please sign in to comment.