Skip to content

Commit

Permalink
Improve lambda type check by name for java21. Fix #300 (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
gayanper authored Sep 5, 2023
1 parent d7b107e commit 9e3e8ec
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -41,6 +42,7 @@
public class LambdaUtils {

private static final String LAMBDA_METHOD_PREFIX = "lambda$"; //$NON-NLS-1$
private static final Pattern LAMBDA_TYPE_PATTERN = Pattern.compile(".*\\$\\$Lambda[\\$,\\.].*"); //$NON-NLS-1$

/**
* Inspects the top stack frame of the context; if that frame is a lambda frame, looks for a variable with the specified name in that frame and
Expand Down Expand Up @@ -205,7 +207,8 @@ public static boolean isLambdaFrame(IJavaStackFrame frame) throws DebugException
* @since 3.15
*/
public static boolean isLambdaField(IVariable variable) throws DebugException {
return (variable instanceof IJavaFieldVariable) && ((IJavaFieldVariable) variable).getDeclaringType().getName().contains("$Lambda$"); //$NON-NLS-1$
return (variable instanceof IJavaFieldVariable) &&
LAMBDA_TYPE_PATTERN.matcher(((IJavaFieldVariable) variable).getDeclaringType().getName()).matches();
}

/**
Expand Down

0 comments on commit 9e3e8ec

Please sign in to comment.