diff --git a/test/hotspot/jtreg/compiler/exceptions/IllegalAccessInCatch.jasm b/test/hotspot/jtreg/compiler/exceptions/IllegalAccessInCatch.jasm index beeffa69a97..78be0bbb177 100644 --- a/test/hotspot/jtreg/compiler/exceptions/IllegalAccessInCatch.jasm +++ b/test/hotspot/jtreg/compiler/exceptions/IllegalAccessInCatch.jasm @@ -46,6 +46,7 @@ super class IllegalAccessInCatch idiv; endtry t0; ireturn; + catch t0 java/lang/IllegalAccessError; catch t0 jdk/internal/agent/AgentConfigurationError; // loadable but not accessible from unnamed module stack_frame_type full; stack_map class java/lang/Throwable; diff --git a/test/hotspot/jtreg/compiler/exceptions/TestAccessErrorInCatch.java b/test/hotspot/jtreg/compiler/exceptions/TestAccessErrorInCatch.java index 46541d76016..d63e4254ca4 100644 --- a/test/hotspot/jtreg/compiler/exceptions/TestAccessErrorInCatch.java +++ b/test/hotspot/jtreg/compiler/exceptions/TestAccessErrorInCatch.java @@ -62,6 +62,11 @@ public static void main(String[] args) throws Throwable { } private static int invoke(MethodHandle mh) throws Throwable { - return (int) mh.invokeExact(); + int expected = 1; + int ret = (int) mh.invokeExact(); + if (ret != expected) { + throw new RuntimeException("Returned " + ret + " but expected " + expected); + } + return ret; } }