Skip to content
Permalink
Browse files
8264663: Update test SuspendWithCurrentThread.java to verify that sus…
…pend doesn't exit until resumed

Reviewed-by: dcubed, sspitsyn
  • Loading branch information
lmesnik committed Apr 26, 2021
1 parent b524a81 commit b5c6351315eeec64fe9c06fc7c8719efa08dc8a6
Showing 1 changed file with 8 additions and 1 deletion.
@@ -22,13 +22,15 @@
*/

#include <string.h>
#include <atomic>
#include "jvmti.h"

extern "C" {

static jvmtiEnv* jvmti = NULL;
static jthread* threads = NULL;
static jsize threads_count = 0;
static std::atomic<bool> is_exited_from_suspend;

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

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

LOG("suspendTestedThreads: check and print SuspendThreadList results:");
@@ -102,6 +105,10 @@ Java_SuspendWithCurrentThread_checkTestedThreadsSuspended(JNIEnv *jni, jclass cl
return JNI_FALSE;
}
}
if (is_exited_from_suspend.load()) {
LOG("Thread didn't stop in self suspend.");
return JNI_FALSE;
}
LOG("checkTestedThreadsSuspended: finished\n");
return JNI_TRUE;
}
@@ -155,7 +162,7 @@ Java_SuspendWithCurrentThread_releaseTestedThreadsInfo(JNIEnv *jni, jclass cls)
JNIEXPORT jint JNICALL
Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
LOG("\nAgent_OnLoad started");

is_exited_from_suspend.store(false);
// create JVMTI environment
if (jvm->GetEnv((void **) (&jvmti), JVMTI_VERSION) != JNI_OK) {
return JNI_ERR;

1 comment on commit b5c6351

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b5c6351 Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.