< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/em02t001.cpp
Print this page
rev 52028 : 8211801: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/scenarios/[A-E]
Summary:
Reviewed-by:
@@ -66,12 +66,11 @@
jint threads_count = 0;
jthread returnValue = NULL;
int i;
/* get all live threads */
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
+ if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
return NULL;
if (!NSK_VERIFY(threads != NULL))
return NULL;
@@ -79,23 +78,21 @@
for (i = 0; i < threads_count; i++) {
if (!NSK_VERIFY(threads[i] != NULL))
break;
/* get thread information */
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
+ if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
break;
/* find by name */
if (info.name != NULL && (strcmp(info.name, threadName) == 0)) {
returnValue = threads[i];
}
}
/* deallocate threads list */
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
+ if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
return NULL;
return returnValue;
}
@@ -106,20 +103,18 @@
const char* signature) {
jfieldID fieldID;
jclass klass = NULL;
- if (!NSK_JNI_VERIFY(jni, (klass =
- NSK_CPP_STUB2(FindClass, jni, className)) != NULL))
+ if (!NSK_JNI_VERIFY(jni, (klass = jni->FindClass(className)) != NULL))
return NULL;
if (!NSK_JNI_VERIFY(jni, (fieldID =
- NSK_CPP_STUB4(GetStaticFieldID, jni, klass, objFieldName,
- signature)) != NULL))
+ jni->GetStaticFieldID(klass, objFieldName, signature)) != NULL))
return NULL;
- return NSK_CPP_STUB3(GetStaticObjectField, jni, klass, fieldID);
+ return jni->GetStaticObjectField(klass, fieldID);
}
/* ============================================================================= */
static int prepare() {
@@ -128,44 +123,40 @@
NSK_COMPLAIN1("<%s> thread not found\n", MAIN_THREAD_NAME);
return NSK_FALSE;
}
/* make thread accessable for a long time */
- if (!NSK_JNI_VERIFY(jni, (mainThread =
- NSK_CPP_STUB2(NewGlobalRef, jni, mainThread)) != NULL))
+ if (!NSK_JNI_VERIFY(jni, (mainThread = jni->NewGlobalRef(mainThread)) != NULL))
return NSK_FALSE;
if (!NSK_VERIFY((startObject =
getStaticObjField(DEBUGEE_CLASS_NAME, START_FIELD_NAME,
OBJECT_FIELD_SIG)) != NULL))
return NSK_FALSE;
/*make object accessable for a long time*/
- if (!NSK_JNI_VERIFY(jni, (startObject =
- NSK_CPP_STUB2(NewGlobalRef, jni, startObject)) != NULL))
+ if (!NSK_JNI_VERIFY(jni, (startObject = jni->NewGlobalRef(startObject)) != NULL))
return NSK_FALSE;
if (!NSK_VERIFY((endObject =
getStaticObjField(DEBUGEE_CLASS_NAME, END_FIELD_NAME,
OBJECT_FIELD_SIG)) != NULL))
return NSK_FALSE;
/*make object accessable for a long time*/
- if (!NSK_JNI_VERIFY(jni, (endObject =
- NSK_CPP_STUB2(NewGlobalRef, jni, endObject)) != NULL))
+ if (!NSK_JNI_VERIFY(jni, (endObject = jni->NewGlobalRef(endObject)) != NULL))
return NSK_FALSE;
if (!NSK_VERIFY((debuggeeThread =
(jthread)getStaticObjField(DEBUGEE_CLASS_NAME, THREAD_FIELD_NAME,
THREAD_FIELD_SIG)) != NULL))
return NSK_FALSE;
/* make thread accessable for a long time */
- if (!NSK_JNI_VERIFY(jni, (debuggeeThread =
- NSK_CPP_STUB2(NewGlobalRef, jni, debuggeeThread)) != NULL))
+ if (!NSK_JNI_VERIFY(jni, (debuggeeThread = jni->NewGlobalRef(debuggeeThread)) != NULL))
return NSK_FALSE;
return NSK_TRUE;
}
@@ -174,19 +165,19 @@
static int
clean() {
/* disable MonitorContendedEnter event */
if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB4(SetEventNotificationMode, jvmti, JVMTI_DISABLE,
- JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL)))
+ jvmti->SetEventNotificationMode(
+ JVMTI_DISABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, NULL)))
nsk_jvmti_setFailStatus();
/* dispose global references */
- NSK_CPP_STUB2(DeleteGlobalRef, jni, startObject);
- NSK_CPP_STUB2(DeleteGlobalRef, jni, endObject);
- NSK_CPP_STUB2(DeleteGlobalRef, jni, debuggeeThread);
- NSK_CPP_STUB2(DeleteGlobalRef, jni, mainThread);
+ jni->DeleteGlobalRef(startObject);
+ jni->DeleteGlobalRef(endObject);
+ jni->DeleteGlobalRef(debuggeeThread);
+ jni->DeleteGlobalRef(mainThread);
startObject = NULL;
endObject = NULL;
debuggeeThread = NULL;
mainThread = NULL;
@@ -217,28 +208,27 @@
/* get thread information */
static void
showThreadInfo(jthread thread) {
jvmtiThreadInfo info;
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB3(GetThreadInfo, jvmti, thread, &info)))
+ if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info)))
return;
NSK_DISPLAY2("\tthread (%s): %p\n", info.name, thread);
}
/* ============================================================================= */
static void
changeCount(jvmtiEvent event, int *currentCounts) {
- if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, syncLock)))
+ if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(syncLock)))
nsk_jvmti_setFailStatus();
currentCounts[event - JVMTI_MIN_EVENT_TYPE_VAL]++;
- if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, syncLock)))
+ if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(syncLock)))
nsk_jvmti_setFailStatus();
}
/* ============================================================================= */
@@ -325,12 +315,11 @@
showEventStatistics(STEP_AMOUNT);
if (!checkEvents(STEP_AMOUNT)) {
nsk_jvmti_setFailStatus();
}
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB2(DestroyRawMonitor, jvmti, syncLock)))
+ if (!NSK_JVMTI_VERIFY(jvmti->DestroyRawMonitor(syncLock)))
nsk_jvmti_setFailStatus();
}
void JNICALL
@@ -418,17 +407,17 @@
if (expectedThread == NULL || expectedObject == NULL)
return;
/* check if event is for tested thread and for tested object */
- if (NSK_CPP_STUB3(IsSameObject, jni_env, expectedThread, thread) &&
- NSK_CPP_STUB3(IsSameObject, jni_env, expectedObject, object)) {
+ if (jni_env->IsSameObject(expectedThread, thread) &&
+ jni_env->IsSameObject(expectedObject, object)) {
NSK_DISPLAY1("--->%-40s is received\n", TranslateEvent(event));
showThreadInfo(thread);
- if (NSK_CPP_STUB3(IsSameObject, jni_env, expectedObject, endObject))
+ if (jni_env->IsSameObject(expectedObject, endObject))
NSK_DISPLAY0("\tobject: 'endingMonitor'\n");
else
NSK_DISPLAY0("\tobject: 'startingMonitor'\n");
changeCount(event, &eventCount[0]);
@@ -504,17 +493,17 @@
if (expectedThread == NULL || expectedObject == NULL)
return;
/* check if event is for tested thread and for tested object */
- if (NSK_CPP_STUB3(IsSameObject, jni_env, expectedThread, thread) &&
- NSK_CPP_STUB3(IsSameObject, jni_env, expectedObject, object)) {
+ if (jni_env->IsSameObject(expectedThread, thread) &&
+ jni_env->IsSameObject(expectedObject, object)) {
NSK_DISPLAY1("--->%-40s is received (new callbacks)\n", TranslateEvent(event));
showThreadInfo(thread);
- if (NSK_CPP_STUB3(IsSameObject, jni_env, expectedObject, endObject))
+ if (jni_env->IsSameObject(expectedObject, endObject))
NSK_DISPLAY0("\tobject: 'endingMonitor'\n");
else
NSK_DISPLAY0("\tobject: 'startingMonitor'\n");
@@ -570,20 +559,17 @@
&& (event != JVMTI_EVENT_MONITOR_CONTENDED_ENTER)
&& (event != JVMTI_EVENT_MONITOR_CONTENDED_ENTERED)
&& (event != JVMTI_EVENT_MONITOR_WAIT)
&& (event != JVMTI_EVENT_MONITOR_WAITED)) {
if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
- NSK_CPP_STUB4(SetEventNotificationMode, jvmti,
- JVMTI_ENABLE, event, NULL))) {
+ jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) {
NSK_COMPLAIN1("Unexpected error enabling %s\n",
TranslateEvent(event));
return NSK_FALSE;
}
} else {
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB4(SetEventNotificationMode, jvmti,
- JVMTI_ENABLE, event, NULL))) {
+ if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, event, NULL))) {
NSK_COMPLAIN1("Unexpected error enabling %s\n",
TranslateEvent(event));
return NSK_FALSE;
}
}
@@ -677,14 +663,11 @@
eventCallbacks.VMDeath = cbVMDeath;
break;
}
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB3(SetEventCallbacks, jvmti,
- &eventCallbacks,
- sizeof(eventCallbacks))))
+ if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
return NSK_FALSE;
return NSK_TRUE;
}
@@ -769,22 +752,21 @@
timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB3(CreateRawMonitor, jvmti, "_syncLock", &syncLock))) {
+ if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_syncLock", &syncLock))) {
nsk_jvmti_setFailStatus();
return JNI_ERR;
}
{
jvmtiCapabilities caps;
memset(&caps, 0, sizeof(caps));
caps.can_generate_monitor_events = 1;
- if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
+ if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
return JNI_ERR;
}
if (!setCallBacks(1)) {
return JNI_ERR;
< prev index next >