Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions test/jdk/java/foreign/sharedclosejvmti/TestSharedCloseJvmti.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2026, 2026 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @bug 8370344
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down