< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI01/ji01t001/ji01t001.cpp
Print this page
rev 52050 : [mq]: refactor
@@ -68,18 +68,11 @@
/* ====================================================================== */
static jvmtiPhase getVMPhase(jvmtiEnv *jvmti) {
jvmtiPhase phase;
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB2(
- GetPhase
- , jvmti
- , &phase
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&phase)))
exit(NSK_STATUS_FAILED);
return phase;
}
@@ -87,18 +80,12 @@
static void doRedirect(jvmtiEnv *jvmti, jvmtiPhase phase) {
jvmtiError err;
NSK_DISPLAY0("doRedirect: obtaining the JNI function table ...\n");
// Store original function table
- if (!NSK_VERIFY(
- (err = NSK_CPP_STUB2(
- GetJNIFunctionTable
- , jvmti
- , &orig_jni_functions
- )) == JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE
- )
- )
+ err = jvmti->GetJNIFunctionTable(&orig_jni_functions);
+ if (!NSK_VERIFY((err == JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE)))
{
NSK_COMPLAIN2("TEST FAILED: failed to get original JNI function table during %s: %s\n"
, TranslatePhase(phase)
, TranslateError(err)
);
@@ -114,17 +101,11 @@
);
}
// Get a duplicate of the function table for future modification
if (!NSK_VERIFY(
- (err = NSK_CPP_STUB2(
- GetJNIFunctionTable
- , jvmti
- , &redir_jni_functions
- )) == JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE
- )
- )
+ (err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) == JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE))
{
NSK_COMPLAIN2("TEST FAILED: failed to get JNI function table for interception during %s: %s\n"
, TranslatePhase(phase)
, TranslateError(err)
);
@@ -146,17 +127,11 @@
redir_jni_functions->FindClass = MyFindClass;
}
// Set new JNI function table
if (!NSK_VERIFY(
- (err = NSK_CPP_STUB2(
- SetJNIFunctionTable
- , jvmti
- , redir_jni_functions
- )) == JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE
- )
- )
+ (err = jvmti->SetJNIFunctionTable(redir_jni_functions)) == JVMTI_ERROR_NONE || phase != JVMTI_PHASE_LIVE))
{
NSK_COMPLAIN2("TEST FAILED: failed to set redirected JNI function table during %s: %s\n"
, TranslatePhase(phase)
, TranslateError(err)
);
@@ -176,18 +151,11 @@
/* ====================================================================== */
static void doRestore(jvmtiEnv *jvmti) {
NSK_DISPLAY0("doRestore: restoring the original JNI function table ...\n");
// Set new JNI function table
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB2(
- SetJNIFunctionTable
- , jvmti
- , orig_jni_functions
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->SetJNIFunctionTable(orig_jni_functions)))
{
NSK_COMPLAIN0("TEST FAILED: failed to restore original JNI function table\n");
result = NSK_STATUS_FAILED;
exit(NSK_STATUS_FAILED);
@@ -196,34 +164,20 @@
NSK_DISPLAY0("doRestore: the original JNI function table is restored successfully\n");
}
/* ====================================================================== */
static void lock(jvmtiEnv *jvmti) {
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB2(
- RawMonitorEnter
- , jvmti
- , eventLock
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(eventLock)))
{
result = NSK_STATUS_FAILED;
exit(NSK_STATUS_FAILED);
}
}
/* ====================================================================== */
static void unlock(jvmtiEnv *jvmti) {
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB2(
- RawMonitorExit
- , jvmti
- , eventLock
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(eventLock)))
{
result = NSK_STATUS_FAILED;
exit(NSK_STATUS_FAILED);
}
}
@@ -237,19 +191,15 @@
)
{
jclass cls;
NSK_TRACE(
- (cls = NSK_CPP_STUB2(
- FindClass
- , env
- , classSig
- ))
+ (cls = env->FindClass(classSig))
);
NSK_TRACE(
- NSK_CPP_STUB1(ExceptionClear, env)
+ env->ExceptionClear()
);
// The check should pass if the actual number of invocations is not less that the expected number (fnd_calls >= exFndCalls).
// If the invocation is not expected (exFndCalls == 0), fnd_calls should be also == 0.
if ((exFndCalls > 0 && fnd_calls >= exFndCalls) || (fnd_calls == exFndCalls)) {
@@ -327,19 +277,11 @@
NSK_TRACE(doRestore(jvmti));
NSK_TRACE(checkCall(env, 2, "VMDeath", TranslatePhase(phase), 0));
(void) memset(&callbacks, 0, sizeof(callbacks));
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB3(
- SetEventCallbacks
- , jvmti
- , &callbacks
- , sizeof(callbacks)
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
result = NSK_STATUS_FAILED;
NSK_TRACE(unlock(jvmti));
if (result == NSK_STATUS_FAILED) {
@@ -371,32 +313,15 @@
)
)
return JNI_ERR;
- if (!NSK_VERIFY(
- NSK_CPP_STUB3(
- GetEnv
- , jvm
- , (void **) &jvmti
- , JVMTI_VERSION_1_1
- ) == JNI_OK
- && jvmti != NULL
- )
- )
+ if (!NSK_VERIFY(jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1) == JNI_OK && jvmti != NULL))
return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB3(
- CreateRawMonitor
- , jvmti
- , "_event_lock"
- , &eventLock
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_event_lock", &eventLock)))
return JNI_ERR;
NSK_DISPLAY1("a) Trying to intercept JNI functions during %s phase ...\n"
, TranslatePhase(getVMPhase(jvmti))
);
@@ -407,47 +332,21 @@
(void) memset(&callbacks, 0, sizeof(callbacks));
callbacks.VMInit = &VMInit;
callbacks.VMDeath = &VMDeath;
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB3(
- SetEventCallbacks
- , jvmti
- , &callbacks
- , sizeof(callbacks)
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
return JNI_ERR;
NSK_DISPLAY0("Event callbacks are set\nEnabling events...\n");
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB4(
- SetEventNotificationMode
- , jvmti
- , JVMTI_ENABLE
- , JVMTI_EVENT_VM_INIT
- , NULL
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL)))
return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(
- NSK_CPP_STUB4(
- SetEventNotificationMode
- , jvmti
- , JVMTI_ENABLE
- , JVMTI_EVENT_VM_DEATH
- , NULL
- )
- )
- )
+ if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
return JNI_ERR;
NSK_DISPLAY0("Events are enabled\n");
return JNI_OK;
< prev index next >