diff --git a/core/test/com/google/inject/MethodInterceptionTest.java b/core/test/com/google/inject/MethodInterceptionTest.java index cc81c49857..d1b1dff1f7 100644 --- a/core/test/com/google/inject/MethodInterceptionTest.java +++ b/core/test/com/google/inject/MethodInterceptionTest.java @@ -305,7 +305,7 @@ protected void configure() { StackTraceElement[] stackTraceElement = t.getStackTrace(); int frame = 0; assertEquals("explode", stackTraceElement[frame++].getMethodName()); - while (stackTraceElement[frame].getClassName().startsWith("java.lang.invoke.LambdaForm")) { + while (isLambdaFrame(stackTraceElement[frame])) { frame++; // ignore lambda frames when running tests with ShowHiddenFrames } assertEquals("invoke", stackTraceElement[frame++].getMethodName()); @@ -315,6 +315,12 @@ protected void configure() { } } + private static boolean isLambdaFrame(StackTraceElement element) { + var name = element.getClassName(); + return name.startsWith("java.lang.invoke.LambdaForm") + || name.startsWith("java.lang.invoke.DirectMethodHandle"); + } + @Test public void testNotInterceptedMethodsInInterceptedClassDontAddFrames() { Injector injector =