Skip to content

Commit 3a4ea1a

Browse files
committed
8381900: Test vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001 does not handle frequent GC gracefully
1 parent 78580f1 commit 3a4ea1a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001/ap03t001.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static jvmtiCapabilities caps;
4242

4343
static volatile int obj_free = 0;
4444
static volatile long obj_count = 0;
45+
static volatile bool check_object_free = true;
4546

4647
static jlong timeout = 0;
4748
static int user_data = 0;
@@ -50,6 +51,9 @@ static const jlong DEBUGEE_CLASS_TAG = (jlong)1024;
5051

5152
void JNICALL
5253
ObjectFree(jvmtiEnv *jvmti_env, jlong tag) {
54+
if (!check_object_free) {
55+
return;
56+
}
5357
NSK_COMPLAIN1("Received unexpected ObjectFree event for an object with tag %ld\n\n", (long)tag);
5458
nsk_jvmti_setFailStatus();
5559
obj_free++;
@@ -190,6 +194,11 @@ agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
190194
} else {
191195
NSK_DISPLAY1("Number of objects IterateOverObjectsReachableFromObject has found: %d\n\n", obj_count);
192196
}
197+
198+
// Ignore late ObjectFree notifications after the resurrected object has
199+
// been validated. At this point the test has already proven that the
200+
// tagged object survived finalization and is reachable through the catcher.
201+
check_object_free = false;
193202
} while (0);
194203

195204
NSK_DISPLAY0("Let debugee to finish\n");

0 commit comments

Comments
 (0)