< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/multienv/MA10/ma10t001/ma10t001.cpp

Print this page
rev 52100 : 8212082: Remove the NSK_CPP_STUB macros for remaining vmTestbase/jvmti/[sS]*
Summary:
Reviewed-by:


  41 static int ExceptionEventsCount = 0;
  42 static int ExceptionCatchEventsCount = 0;
  43 
  44 /* ========================================================================== */
  45 
  46 /** callback functions **/
  47 
  48 static void JNICALL
  49 Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread,
  50         jmethodID method, jlocation location, jobject exception,
  51         jmethodID catch_method, jlocation catch_location) {
  52     jclass klass = NULL;
  53     char *signature = NULL;
  54 
  55     if (!isThreadExpected(jvmti_env, thread)) {
  56         return;
  57     }
  58 
  59     ExceptionEventsCount++;
  60 
  61     if (!NSK_JNI_VERIFY(jni_env, (klass =
  62             NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
  63         nsk_jvmti_setFailStatus();
  64         return;
  65     }
  66     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
  67             klass, &signature, NULL))) {
  68         nsk_jvmti_setFailStatus();
  69         return;
  70     }
  71     NSK_DISPLAY1("Exception event: %s\n", signature);
  72     if (signature != NULL)
  73         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
  74 }
  75 
  76 void JNICALL
  77 ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread,
  78         jmethodID method, jlocation location, jobject exception) {
  79     jclass klass = NULL;
  80     char *signature = NULL;
  81 
  82     if (!isThreadExpected(jvmti_env, thread)) {
  83         return;
  84     }
  85 
  86     ExceptionCatchEventsCount++;
  87 
  88     if (!NSK_JNI_VERIFY(jni_env, (klass =
  89             NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
  90         nsk_jvmti_setFailStatus();
  91         return;
  92     }
  93     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
  94             klass, &signature, NULL))) {
  95         nsk_jvmti_setFailStatus();
  96         return;
  97     }
  98     NSK_DISPLAY1("ExceptionCatch event: %s\n", signature);
  99     if (signature != NULL)
 100         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
 101 }
 102 
 103 /* ========================================================================== */
 104 
 105 /** Agent algorithm. */
 106 static void JNICALL
 107 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
 108 
 109     if (!nsk_jvmti_waitForSync(timeout))
 110         return;
 111 
 112     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
 113             jvmti, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL)))
 114         nsk_jvmti_setFailStatus();
 115     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
 116             jvmti, JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL)))
 117         nsk_jvmti_setFailStatus();
 118 
 119     /* resume debugee and wait for sync */
 120     if (!nsk_jvmti_resumeSync())
 121         return;
 122     if (!nsk_jvmti_waitForSync(timeout))
 123         return;
 124 
 125     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
 126             jvmti, JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL)))
 127         nsk_jvmti_setFailStatus();
 128     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
 129             jvmti, JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL)))
 130         nsk_jvmti_setFailStatus();
 131 
 132     NSK_DISPLAY1("Exception events received: %d\n",
 133         ExceptionEventsCount);
 134     if (!NSK_VERIFY(ExceptionEventsCount == 3))
 135         nsk_jvmti_setFailStatus();
 136 
 137     NSK_DISPLAY1("ExceptionCatch events received: %d\n",
 138         ExceptionCatchEventsCount);
 139     if (!NSK_VERIFY(ExceptionCatchEventsCount == 3))
 140         nsk_jvmti_setFailStatus();
 141 
 142     if (!nsk_jvmti_resumeSync())
 143         return;
 144 }
 145 
 146 /* ========================================================================== */
 147 
 148 /** Agent library initialization. */
 149 #ifdef STATIC_BUILD


 161     jvmtiEnv* jvmti = NULL;
 162     jvmtiCapabilities caps;
 163     jvmtiEventCallbacks callbacks;
 164 
 165     NSK_DISPLAY0("Agent_OnLoad\n");
 166 
 167     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 168         return JNI_ERR;
 169 
 170     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 171 
 172     if (!NSK_VERIFY((jvmti =
 173             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 174         return JNI_ERR;
 175 
 176     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 177         return JNI_ERR;
 178 
 179     memset(&caps, 0, sizeof(caps));
 180     caps.can_generate_exception_events = 1;
 181     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
 182         return JNI_ERR;
 183     }
 184 
 185     memset(&callbacks, 0, sizeof(callbacks));
 186     callbacks.Exception = &Exception;
 187     callbacks.ExceptionCatch = &ExceptionCatch;
 188     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 189         return JNI_ERR;
 190 
 191     return JNI_OK;
 192 }
 193 
 194 /* ========================================================================== */
 195 
 196 }


  41 static int ExceptionEventsCount = 0;
  42 static int ExceptionCatchEventsCount = 0;
  43 
  44 /* ========================================================================== */
  45 
  46 /** callback functions **/
  47 
  48 static void JNICALL
  49 Exception(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread,
  50         jmethodID method, jlocation location, jobject exception,
  51         jmethodID catch_method, jlocation catch_location) {
  52     jclass klass = NULL;
  53     char *signature = NULL;
  54 
  55     if (!isThreadExpected(jvmti_env, thread)) {
  56         return;
  57     }
  58 
  59     ExceptionEventsCount++;
  60 
  61     if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {

  62         nsk_jvmti_setFailStatus();
  63         return;
  64     }
  65     if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {

  66         nsk_jvmti_setFailStatus();
  67         return;
  68     }
  69     NSK_DISPLAY1("Exception event: %s\n", signature);
  70     if (signature != NULL)
  71         jvmti_env->Deallocate((unsigned char*)signature);
  72 }
  73 
  74 void JNICALL
  75 ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread,
  76         jmethodID method, jlocation location, jobject exception) {
  77     jclass klass = NULL;
  78     char *signature = NULL;
  79 
  80     if (!isThreadExpected(jvmti_env, thread)) {
  81         return;
  82     }
  83 
  84     ExceptionCatchEventsCount++;
  85 
  86     if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {

  87         nsk_jvmti_setFailStatus();
  88         return;
  89     }
  90     if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {

  91         nsk_jvmti_setFailStatus();
  92         return;
  93     }
  94     NSK_DISPLAY1("ExceptionCatch event: %s\n", signature);
  95     if (signature != NULL)
  96         jvmti_env->Deallocate((unsigned char*)signature);
  97 }
  98 
  99 /* ========================================================================== */
 100 
 101 /** Agent algorithm. */
 102 static void JNICALL
 103 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
 104 
 105     if (!nsk_jvmti_waitForSync(timeout))
 106         return;
 107 
 108     if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION, NULL)))

 109         nsk_jvmti_setFailStatus();
 110     if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL)))

 111         nsk_jvmti_setFailStatus();
 112 
 113     /* resume debugee and wait for sync */
 114     if (!nsk_jvmti_resumeSync())
 115         return;
 116     if (!nsk_jvmti_waitForSync(timeout))
 117         return;
 118 
 119     if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION, NULL)))

 120         nsk_jvmti_setFailStatus();
 121     if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_EXCEPTION_CATCH, NULL)))

 122         nsk_jvmti_setFailStatus();
 123 
 124     NSK_DISPLAY1("Exception events received: %d\n",
 125         ExceptionEventsCount);
 126     if (!NSK_VERIFY(ExceptionEventsCount == 3))
 127         nsk_jvmti_setFailStatus();
 128 
 129     NSK_DISPLAY1("ExceptionCatch events received: %d\n",
 130         ExceptionCatchEventsCount);
 131     if (!NSK_VERIFY(ExceptionCatchEventsCount == 3))
 132         nsk_jvmti_setFailStatus();
 133 
 134     if (!nsk_jvmti_resumeSync())
 135         return;
 136 }
 137 
 138 /* ========================================================================== */
 139 
 140 /** Agent library initialization. */
 141 #ifdef STATIC_BUILD


 153     jvmtiEnv* jvmti = NULL;
 154     jvmtiCapabilities caps;
 155     jvmtiEventCallbacks callbacks;
 156 
 157     NSK_DISPLAY0("Agent_OnLoad\n");
 158 
 159     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 160         return JNI_ERR;
 161 
 162     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 163 
 164     if (!NSK_VERIFY((jvmti =
 165             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 166         return JNI_ERR;
 167 
 168     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 169         return JNI_ERR;
 170 
 171     memset(&caps, 0, sizeof(caps));
 172     caps.can_generate_exception_events = 1;
 173     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
 174         return JNI_ERR;
 175     }
 176 
 177     memset(&callbacks, 0, sizeof(callbacks));
 178     callbacks.Exception = &Exception;
 179     callbacks.ExceptionCatch = &ExceptionCatch;
 180     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 181         return JNI_ERR;
 182 
 183     return JNI_OK;
 184 }
 185 
 186 /* ========================================================================== */
 187 
 188 }
< prev index next >