Skip to content

Commit b5c6351

Browse files
committed
8264663: Update test SuspendWithCurrentThread.java to verify that suspend doesn't exit until resumed
Reviewed-by: dcubed, sspitsyn
1 parent b524a81 commit b5c6351

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/hotspot/jtreg/serviceability/jvmti/SuspendWithCurrentThread/libSuspendWithCurrentThread.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
*/
2323

2424
#include <string.h>
25+
#include <atomic>
2526
#include "jvmti.h"
2627

2728
extern "C" {
2829

2930
static jvmtiEnv* jvmti = NULL;
3031
static jthread* threads = NULL;
3132
static jsize threads_count = 0;
33+
static std::atomic<bool> is_exited_from_suspend;
3234

3335
#define LOG(...) \
3436
do { \
@@ -74,6 +76,7 @@ Java_ThreadToSuspend_suspendTestedThreads(JNIEnv *jni, jclass cls) {
7476

7577
LOG("suspendTestedThreads: before JVMTI SuspendThreadList");
7678
err = jvmti->SuspendThreadList(threads_count, threads, results);
79+
is_exited_from_suspend.store(true);
7780
check_jvmti_status(jni, err, "suspendTestedThreads: error in JVMTI SuspendThreadList");
7881

7982
LOG("suspendTestedThreads: check and print SuspendThreadList results:");
@@ -102,6 +105,10 @@ Java_SuspendWithCurrentThread_checkTestedThreadsSuspended(JNIEnv *jni, jclass cl
102105
return JNI_FALSE;
103106
}
104107
}
108+
if (is_exited_from_suspend.load()) {
109+
LOG("Thread didn't stop in self suspend.");
110+
return JNI_FALSE;
111+
}
105112
LOG("checkTestedThreadsSuspended: finished\n");
106113
return JNI_TRUE;
107114
}
@@ -155,7 +162,7 @@ Java_SuspendWithCurrentThread_releaseTestedThreadsInfo(JNIEnv *jni, jclass cls)
155162
JNIEXPORT jint JNICALL
156163
Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
157164
LOG("\nAgent_OnLoad started");
158-
165+
is_exited_from_suspend.store(false);
159166
// create JVMTI environment
160167
if (jvm->GetEnv((void **) (&jvmti), JVMTI_VERSION) != JNI_OK) {
161168
return JNI_ERR;

0 commit comments

Comments
 (0)