< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach021/attach021Agent00.cpp

Print this page
rev 52828 : 8213501: Deploy ExceptionJniWrapper for a few tests
Summary:
Reviewed-by:

@@ -25,10 +25,11 @@
 #include <string.h>
 #include <jni.h>
 #include <jvmti.h>
 #include <aod.h>
 #include <jvmti_aod.h>
+#include "ExceptionCheckingJniEnv.hpp"
 
 extern "C" {
 
 /*
  * Expected agent work scenario:

@@ -85,28 +86,20 @@
      * Can't use JNI functions from ObjectFree event handler, in this test target application calls
      * function nsk_aod_agentFinished
      */
 }
 
-int registerNativeMethods(JNIEnv* jni) {
+void registerNativeMethods(JNIEnv* jni_env) {
+    ExceptionCheckingJniEnvPtr jni(jni_env);
     jclass appClass;
     JNINativeMethod nativeMethods[] = {
             { (char*) "setTagFor", (char*) "(Ljava/lang/Object;)Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_setTagFor },
             { (char*) "shutdownAgent", (char*) "()V", (void*) Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_shutdownAgent } };
     jint nativeMethodsNumber = 2;
 
-    appClass = jni->FindClass(ATTACH021_TARGET_APP_CLASS_NAME);
-    if (!NSK_JNI_VERIFY(jni, appClass != NULL)) {
-        return NSK_FALSE;
-    }
-
-    if (!NSK_JNI_VERIFY(jni,
-            (jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber) == 0))) {
-        return NSK_FALSE;
-    }
-
-    return NSK_TRUE;
+    appClass = jni->FindClass(ATTACH021_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
+    jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
 }
 
 #ifdef STATIC_BUILD
 JNIEXPORT jint JNI_OnLoad_attach021Agent00(JavaVM *jvm, char *options, void *reserved) {
     return JNI_VERSION_1_8;

@@ -136,13 +129,11 @@
 
     jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved);
     if (!NSK_VERIFY(jvmti != NULL))
         return JNI_ERR;
 
-    if (!NSK_VERIFY(registerNativeMethods(jni))) {
-        return JNI_ERR;
-    }
+    registerNativeMethods(jni);
 
     memset(&caps, 0, sizeof(caps));
     caps.can_tag_objects = 1;
     caps.can_generate_object_free_events = 1;
     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
< prev index next >