< prev index next >

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

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


  37 /* scaffold objects */
  38 static jlong timeout = 0;
  39 
  40 /* event counts */
  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     ExceptionEventsCount++;
  56 
  57     if (!NSK_JNI_VERIFY(jni_env, (klass =
  58             NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
  59         nsk_jvmti_setFailStatus();
  60         return;
  61     }
  62     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
  63             klass, &signature, NULL))) {
  64         nsk_jvmti_setFailStatus();
  65         return;
  66     }
  67     NSK_DISPLAY1("Exception event: %s\n", signature);
  68     if (signature != NULL)
  69         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
  70 }
  71 
  72 void JNICALL
  73 ExceptionCatch(jvmtiEnv *jvmti_env, JNIEnv *jni_env, jthread thread,
  74         jmethodID method, jlocation location, jobject exception) {
  75     jclass klass = NULL;
  76     char *signature = NULL;
  77 
  78     ExceptionCatchEventsCount++;
  79 
  80     if (!NSK_JNI_VERIFY(jni_env, (klass =
  81             NSK_CPP_STUB2(GetObjectClass, jni_env, exception)) != NULL)) {
  82         nsk_jvmti_setFailStatus();
  83         return;
  84     }
  85     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(GetClassSignature, jvmti_env,
  86             klass, &signature, NULL))) {
  87         nsk_jvmti_setFailStatus();
  88         return;
  89     }
  90     NSK_DISPLAY1("ExceptionCatch event: %s\n", signature);
  91     if (signature != NULL)
  92         NSK_CPP_STUB2(Deallocate, jvmti_env, (unsigned char*)signature);
  93 }
  94 
  95 /* ========================================================================== */
  96 
  97 /** Agent algorithm. */
  98 static void JNICALL
  99 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
 100 
 101     if (!nsk_jvmti_waitForSync(timeout))
 102         return;
 103 
 104     /* resume debugee and wait for sync */
 105     if (!nsk_jvmti_resumeSync())
 106         return;
 107     if (!nsk_jvmti_waitForSync(timeout))
 108         return;
 109 
 110     NSK_DISPLAY1("Exception events received: %d\n",
 111         ExceptionEventsCount);
 112     if (!NSK_VERIFY(ExceptionEventsCount == 0))


 139     jvmtiEnv* jvmti = NULL;
 140     jvmtiCapabilities caps;
 141     jvmtiEventCallbacks callbacks;
 142 
 143     NSK_DISPLAY0("Agent_OnLoad\n");
 144 
 145     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 146         return JNI_ERR;
 147 
 148     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 149 
 150     if (!NSK_VERIFY((jvmti =
 151             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 152         return JNI_ERR;
 153 
 154     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 155         return JNI_ERR;
 156 
 157     memset(&caps, 0, sizeof(caps));
 158     caps.can_generate_exception_events = 1;
 159     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
 160         return JNI_ERR;
 161     }
 162 
 163     memset(&callbacks, 0, sizeof(callbacks));
 164     callbacks.Exception = &Exception;
 165     callbacks.ExceptionCatch = &ExceptionCatch;
 166     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 167         return JNI_ERR;
 168 
 169     return JNI_OK;
 170 }
 171 
 172 /* ========================================================================== */
 173 
 174 }


  37 /* scaffold objects */
  38 static jlong timeout = 0;
  39 
  40 /* event counts */
  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     ExceptionEventsCount++;
  56 
  57     if (!NSK_JNI_VERIFY(jni_env, (klass = jni_env->GetObjectClass(exception)) != NULL)) {

  58         nsk_jvmti_setFailStatus();
  59         return;
  60     }
  61     if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {

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

  79         nsk_jvmti_setFailStatus();
  80         return;
  81     }
  82     if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &signature, NULL))) {

  83         nsk_jvmti_setFailStatus();
  84         return;
  85     }
  86     NSK_DISPLAY1("ExceptionCatch event: %s\n", signature);
  87     if (signature != NULL)
  88         jvmti_env->Deallocate((unsigned char*)signature);
  89 }
  90 
  91 /* ========================================================================== */
  92 
  93 /** Agent algorithm. */
  94 static void JNICALL
  95 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  96 
  97     if (!nsk_jvmti_waitForSync(timeout))
  98         return;
  99 
 100     /* resume debugee and wait for sync */
 101     if (!nsk_jvmti_resumeSync())
 102         return;
 103     if (!nsk_jvmti_waitForSync(timeout))
 104         return;
 105 
 106     NSK_DISPLAY1("Exception events received: %d\n",
 107         ExceptionEventsCount);
 108     if (!NSK_VERIFY(ExceptionEventsCount == 0))


 135     jvmtiEnv* jvmti = NULL;
 136     jvmtiCapabilities caps;
 137     jvmtiEventCallbacks callbacks;
 138 
 139     NSK_DISPLAY0("Agent_OnLoad\n");
 140 
 141     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 142         return JNI_ERR;
 143 
 144     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 145 
 146     if (!NSK_VERIFY((jvmti =
 147             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 148         return JNI_ERR;
 149 
 150     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 151         return JNI_ERR;
 152 
 153     memset(&caps, 0, sizeof(caps));
 154     caps.can_generate_exception_events = 1;
 155     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
 156         return JNI_ERR;
 157     }
 158 
 159     memset(&callbacks, 0, sizeof(callbacks));
 160     callbacks.Exception = &Exception;
 161     callbacks.ExceptionCatch = &ExceptionCatch;
 162     if (!NSK_VERIFY(nsk_jvmti_init_MA(&callbacks)))
 163         return JNI_ERR;
 164 
 165     return JNI_OK;
 166 }
 167 
 168 /* ========================================================================== */
 169 
 170 }
< prev index next >