diff --git a/test/jdk/java/foreign/sharedclosejvmti/TestSharedCloseJvmti.java b/test/jdk/java/foreign/sharedclosejvmti/TestSharedCloseJvmti.java index 9fba092744e..037b34f31fb 100644 --- a/test/jdk/java/foreign/sharedclosejvmti/TestSharedCloseJvmti.java +++ b/test/jdk/java/foreign/sharedclosejvmti/TestSharedCloseJvmti.java @@ -21,6 +21,12 @@ * questions. */ +/* + * =========================================================================== + * (c) Copyright IBM Corp. 2026, 2026 All Rights Reserved + * =========================================================================== + */ + /* * @test * @bug 8370344 @@ -71,9 +77,9 @@ public static class EventDuringScopedAccessRunner { static final int ADDED_FRAMES = 10; static final CountDownLatch MAIN_LATCH = new CountDownLatch(1); - static final CountDownLatch TARGET_LATCH = new CountDownLatch(1); static volatile int SINK; + static volatile boolean CLOSED = false; public static void main(String[] args) throws Throwable { try (Arena arena = Arena.ofShared()) { @@ -88,8 +94,8 @@ public static void main(String[] args) throws Throwable { // wait until trigger thread is in JVMTI event callback MAIN_LATCH.await(); } - // Notify trigger thread that arena was closed - TARGET_LATCH.countDown(); + // Publish that the arena has been closed (Trigger thread spins on CLOSED) + CLOSED = true; } static boolean reentrant = false; @@ -121,11 +127,8 @@ private static void addFrames(int depth) { if (depth >= ADDED_FRAMES) { // notify main thread to close the arena MAIN_LATCH.countDown(); - try { - // wait here until main thread has closed arena - TARGET_LATCH.await(); - } catch (InterruptedException ex) { - throw new RuntimeException("Unexpected interruption"); + while (!CLOSED) { + Thread.onSpinWait(); } return; }