Skip to content
Permalink
Browse files
libVThreadMonitorTest.cpp fixed.
  • Loading branch information
lmesnik committed Mar 6, 2021
1 parent 6e9d313 commit 92ab9a1440ad9123edd00ddbb83a7e27f9fb057e
Showing with 17 additions and 17 deletions.
  1. +17 −17 test/hotspot/jtreg/serviceability/jvmti/vthread/VThreadMonitorTest/libVThreadMonitorTest.cpp
@@ -29,14 +29,14 @@

extern "C" {

#define PASSED 0
#define FAILED 2
#define STATUS_PASSED 0
#define STATUS_FAILED 2

#define TEST_CLASS "VThreadMonitorTest"

static jvmtiEnv *jvmti = NULL;
static volatile jboolean event_has_posted = JNI_FALSE;
static volatile jint status = PASSED;
static volatile jint status = STATUS_PASSED;
static volatile jclass test_class = NULL;

static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
@@ -75,7 +75,7 @@ check_contended_monitor(jvmtiEnv *jvmti, JNIEnv *jni, const char* func,
err = jvmti->GetCurrentContendedMonitor(thread, &contended_monitor);
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, func, "error in JVMTI GetCurrentContendedMonitor");
status = FAILED;
status = STATUS_FAILED;
return;
}

@@ -85,7 +85,7 @@ check_contended_monitor(jvmtiEnv *jvmti, JNIEnv *jni, const char* func,
if (jni->IsSameObject(monitor1, contended_monitor) == JNI_FALSE &&
jni->IsSameObject(monitor2, contended_monitor) == JNI_FALSE) {
printf("FAIL: is_vt: %d: unexpected monitor from GetCurrentContendedMonitor\n", is_vt);
status = FAILED;
status = STATUS_FAILED;
return;
}
printf("%s: GetCurrentContendedMonitor returned expected monitor for %s\n", func, tname);
@@ -94,7 +94,7 @@ check_contended_monitor(jvmtiEnv *jvmti, JNIEnv *jni, const char* func,
err = jvmti->GetThreadState(thread, &state);
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, func, "error in JVMTI GetThreadState");
status = FAILED;
status = STATUS_FAILED;
return;
}
printf("%s: GetThreadState returned state for %s: %0x\n\n", func, tname, state);
@@ -113,20 +113,20 @@ check_owned_monitor(jvmtiEnv *jvmti, JNIEnv *jni, const char* func,
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, func,
"error in JVMTI GetOwnedMonitorInfo");
status = FAILED;
status = STATUS_FAILED;
return;
}
printf("\n%s: GetOwnedMonitorInfo: %s owns %d monitor(s)\n", func, tname, mcount);
jvmti->Deallocate((unsigned char *)owned_monitors);

if (is_vt == JNI_TRUE && mcount < 2) {
fprintf(stderr, "%s: FAIL: monitorCount for %s expected to be >= 2\n", func, tname);
status = FAILED;
status = STATUS_FAILED;
return;
}
if (is_vt == JNI_FALSE && mcount != 0) {
fprintf(stderr, "%s: FAIL: monitorCount for %s expected to be 0\n", func, tname);
status = FAILED;
status = STATUS_FAILED;
return;
}

@@ -136,7 +136,7 @@ check_owned_monitor(jvmtiEnv *jvmti, JNIEnv *jni, const char* func,
err = jvmti->GetThreadState(thread, &state);
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, func, "error in JVMTI GetThreadState");
status = FAILED;
status = STATUS_FAILED;
return;
}
printf("%s: GetThreadState returned state for %s: %0x\n\n", func, tname, state);
@@ -160,15 +160,15 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, jobject mon
ShowErrorMessage(jvmti, err, "MonitorContendedEnter",
"error in JVMTI GetCarrierThread");
event_has_posted = JNI_TRUE;
status = FAILED;
status = STATUS_FAILED;
return;
}

err = jvmti->GetThreadInfo(vthread, &vt_info);
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, "MonitorContendedEnter",
"error in JVMTI GetThreadInfo");
status = FAILED;
status = STATUS_FAILED;
event_has_posted = JNI_TRUE;
return;
}
@@ -177,7 +177,7 @@ MonitorContendedEnter(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, jobject mon
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, "MonitorContendedEnter",
"error in JVMTI GetThreadInfo");
status = FAILED;
status = STATUS_FAILED;
event_has_posted = JNI_TRUE;
return;
}
@@ -211,23 +211,23 @@ MonitorContendedEntered(jvmtiEnv *jvmti, JNIEnv *jni, jthread vthread, jobject m
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, "MonitorContendedEntered",
"error in JVMTI GetCarrierThread");
status = FAILED;
status = STATUS_FAILED;
return;
}

err = jvmti->GetThreadInfo(vthread, &vt_info);
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, "MonitorContendedEntered",
"error in JVMTI GetThreadInfo for virtual thread");
status = FAILED;
status = STATUS_FAILED;
return;
}

err = jvmti->GetThreadInfo(cthread, &ct_info);
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, "MonitorContendedEntered",
"error in JVMTI GetThreadInfo for carrier thread");
status = FAILED;
status = STATUS_FAILED;
return;
}

@@ -364,7 +364,7 @@ Java_VThreadMonitorTest_checkContendedMonitor(JNIEnv *jni, jclass cls, jthread v
if (err != JVMTI_ERROR_NONE) {
ShowErrorMessage(jvmti, err, "MonitorContendedEntered",
"error in JVMTI GetThreadInfo");
status = FAILED;
status = STATUS_FAILED;
return;
}

0 comments on commit 92ab9a1

Please sign in to comment.