From 84c4fadf63cf77a409475a1058372f6ca6801ec9 Mon Sep 17 00:00:00 2001 From: Jason Feng Date: Thu, 21 Aug 2025 15:03:52 -0400 Subject: [PATCH] BadEnclosingMethodTest runs with -Xfuture and checks NoSuchMethodError This matches OpenJ9 implementation. Signed-off-by: Jason Feng --- .../getEnclosingMethod/BadEnclosingMethodTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/lang/Class/getEnclosingMethod/BadEnclosingMethodTest.java b/test/jdk/java/lang/Class/getEnclosingMethod/BadEnclosingMethodTest.java index f673d01c835..a5b13480c0f 100644 --- a/test/jdk/java/lang/Class/getEnclosingMethod/BadEnclosingMethodTest.java +++ b/test/jdk/java/lang/Class/getEnclosingMethod/BadEnclosingMethodTest.java @@ -26,7 +26,7 @@ * @bug 8350704 * @summary Test behaviors with various bad EnclosingMethod attribute * @library /test/lib - * @run junit BadEnclosingMethodTest + * @run junit/othervm -Xfuture BadEnclosingMethodTest */ import jdk.test.lib.ByteCodeLoader; @@ -104,14 +104,14 @@ void testMalformedTypes() throws Exception { @Test void testAbsentMethods() throws Exception { var absentMethodType = loadTestClass("methodName", "(Ldoes/not/Exist;)V"); - var ex = assertThrows(TypeNotPresentException.class, + var ex = assertThrows(NoSuchMethodError.class, absentMethodType::getEnclosingMethod); - assertEquals("does.not.Exist", ex.typeName()); + assertTrue(ex.getMessage().contains("does/not/Exist")); var absentConstructorType = loadTestClass(INIT_NAME, "(Ldoes/not/Exist;)V"); - ex = assertThrows(TypeNotPresentException.class, + ex = assertThrows(NoSuchMethodError.class, absentConstructorType::getEnclosingConstructor); - assertEquals("does.not.Exist", ex.typeName()); + assertTrue(ex.getMessage().contains("does/not/Exist")); } }