Skip to content

Commit 5e17283

Browse files
cushonGuice Team
authored and
Guice Team
committed
Prepare MethodInterceptionTest for an upcoming JDK version
PiperOrigin-RevId: 755050401
1 parent 28526f0 commit 5e17283

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/test/com/google/inject/MethodInterceptionTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ protected void configure() {
305305
StackTraceElement[] stackTraceElement = t.getStackTrace();
306306
int frame = 0;
307307
assertEquals("explode", stackTraceElement[frame++].getMethodName());
308-
while (stackTraceElement[frame].getClassName().startsWith("java.lang.invoke.LambdaForm")) {
308+
while (isLambdaFrame(stackTraceElement[frame])) {
309309
frame++; // ignore lambda frames when running tests with ShowHiddenFrames
310310
}
311311
assertEquals("invoke", stackTraceElement[frame++].getMethodName());
@@ -315,6 +315,12 @@ protected void configure() {
315315
}
316316
}
317317

318+
private static boolean isLambdaFrame(StackTraceElement element) {
319+
var name = element.getClassName();
320+
return name.startsWith("java.lang.invoke.LambdaForm")
321+
|| name.startsWith("java.lang.invoke.DirectMethodHandle");
322+
}
323+
318324
@Test
319325
public void testNotInterceptedMethodsInInterceptedClassDontAddFrames() {
320326
Injector injector =

0 commit comments

Comments
 (0)