< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI01/ji01t001/ji01t001.cpp

Print this page
rev 52050 : [mq]: refactor

*** 68,85 **** /* ====================================================================== */ static jvmtiPhase getVMPhase(jvmtiEnv *jvmti) { jvmtiPhase phase; ! if (!NSK_JVMTI_VERIFY( ! NSK_CPP_STUB2( ! GetPhase ! , jvmti ! , &phase ! ) ! ) ! ) exit(NSK_STATUS_FAILED); return phase; } --- 68,78 ---- /* ====================================================================== */ static jvmtiPhase getVMPhase(jvmtiEnv *jvmti) { jvmtiPhase phase; ! if (!NSK_JVMTI_VERIFY(jvmti->GetPhase(&phase))) exit(NSK_STATUS_FAILED); return phase; }
*** 87,104 **** 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 ! ) ! ) { NSK_COMPLAIN2("TEST FAILED: failed to get original JNI function table during %s: %s\n" , TranslatePhase(phase) , TranslateError(err) ); --- 80,91 ---- static void doRedirect(jvmtiEnv *jvmti, jvmtiPhase phase) { jvmtiError err; NSK_DISPLAY0("doRedirect: obtaining the JNI function table ...\n"); // Store original function table ! 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,130 **** ); } // 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 ! ) ! ) { NSK_COMPLAIN2("TEST FAILED: failed to get JNI function table for interception during %s: %s\n" , TranslatePhase(phase) , TranslateError(err) ); --- 101,111 ---- ); } // Get a duplicate of the function table for future modification if (!NSK_VERIFY( ! (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,162 **** 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 ! ) ! ) { NSK_COMPLAIN2("TEST FAILED: failed to set redirected JNI function table during %s: %s\n" , TranslatePhase(phase) , TranslateError(err) ); --- 127,137 ---- redir_jni_functions->FindClass = MyFindClass; } // Set new JNI function table if (!NSK_VERIFY( ! (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,193 **** /* ====================================================================== */ 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 ! ) ! ) ! ) { NSK_COMPLAIN0("TEST FAILED: failed to restore original JNI function table\n"); result = NSK_STATUS_FAILED; exit(NSK_STATUS_FAILED); --- 151,161 ---- /* ====================================================================== */ static void doRestore(jvmtiEnv *jvmti) { NSK_DISPLAY0("doRestore: restoring the original JNI function table ...\n"); // Set new JNI function table ! 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,229 **** 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 ! ) ! ) ! ) { result = NSK_STATUS_FAILED; exit(NSK_STATUS_FAILED); } } /* ====================================================================== */ static void unlock(jvmtiEnv *jvmti) { ! if (!NSK_JVMTI_VERIFY( ! NSK_CPP_STUB2( ! RawMonitorExit ! , jvmti ! , eventLock ! ) ! ) ! ) { result = NSK_STATUS_FAILED; exit(NSK_STATUS_FAILED); } } --- 164,183 ---- NSK_DISPLAY0("doRestore: the original JNI function table is restored successfully\n"); } /* ====================================================================== */ static void lock(jvmtiEnv *jvmti) { ! if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(eventLock))) { result = NSK_STATUS_FAILED; exit(NSK_STATUS_FAILED); } } /* ====================================================================== */ static void unlock(jvmtiEnv *jvmti) { ! if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(eventLock))) { result = NSK_STATUS_FAILED; exit(NSK_STATUS_FAILED); } }
*** 237,255 **** ) { jclass cls; NSK_TRACE( ! (cls = NSK_CPP_STUB2( ! FindClass ! , env ! , classSig ! )) ); NSK_TRACE( ! NSK_CPP_STUB1(ExceptionClear, env) ); // 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)) { --- 191,205 ---- ) { jclass cls; NSK_TRACE( ! (cls = env->FindClass(classSig)) ); NSK_TRACE( ! 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,345 **** 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) ! ) ! ) ! ) result = NSK_STATUS_FAILED; NSK_TRACE(unlock(jvmti)); if (result == NSK_STATUS_FAILED) { --- 277,287 ---- NSK_TRACE(doRestore(jvmti)); NSK_TRACE(checkCall(env, 2, "VMDeath", TranslatePhase(phase), 0)); (void) memset(&callbacks, 0, 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,402 **** ) ) return JNI_ERR; ! if (!NSK_VERIFY( ! NSK_CPP_STUB3( ! GetEnv ! , jvm ! , (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 ! ) ! ) ! ) return JNI_ERR; NSK_DISPLAY1("a) Trying to intercept JNI functions during %s phase ...\n" , TranslatePhase(getVMPhase(jvmti)) ); --- 313,327 ---- ) ) return JNI_ERR; ! if (!NSK_VERIFY(jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1) == JNI_OK && jvmti != NULL)) return JNI_ERR; ! 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,453 **** (void) memset(&callbacks, 0, sizeof(callbacks)); callbacks.VMInit = &VMInit; callbacks.VMDeath = &VMDeath; ! if (!NSK_JVMTI_VERIFY( ! NSK_CPP_STUB3( ! SetEventCallbacks ! , jvmti ! , &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 ! ) ! ) ! ) return JNI_ERR; ! if (!NSK_JVMTI_VERIFY( ! NSK_CPP_STUB4( ! SetEventNotificationMode ! , jvmti ! , JVMTI_ENABLE ! , JVMTI_EVENT_VM_DEATH ! , NULL ! ) ! ) ! ) return JNI_ERR; NSK_DISPLAY0("Events are enabled\n"); return JNI_OK; --- 332,352 ---- (void) memset(&callbacks, 0, sizeof(callbacks)); callbacks.VMInit = &VMInit; callbacks.VMDeath = &VMDeath; ! 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(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) return JNI_ERR; ! 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 >