< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach009/attach009Agent00.cpp

Print this page
rev 52200 : [mq]: spaces


  65     if (!nsk_jvmti_aod_getClassName(jvmti, klass, loadedClassName)) {
  66         nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_CLASS_LOAD, 0, jvmti, jni);
  67         return;
  68     }
  69 
  70     NSK_DISPLAY2("Class '%s' was loaded by thread '%s'\n", loadedClassName, threadName);
  71 
  72     /*
  73      * When class FIRST_LOADED_CLASS was loaded try to disable events for all threads
  74      * except main target application thread
  75      */
  76     if (strcmp(loadedClassName, FIRST_LOADED_CLASS) == 0) {
  77         strcpy(mainThreadName, threadName);
  78 
  79         if (!nsk_jvmti_aod_disableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD)) {
  80             NSK_COMPLAIN0("Failed to disable events\n");
  81             nsk_aod_agentFinished(jni, agentName, 0);
  82             return;
  83         }
  84 
  85         if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, thread) ) ) {
  86             NSK_COMPLAIN1("Failed to enable events for thread '%s'\n", mainThreadName);
  87             nsk_aod_agentFinished(jni, agentName, 0);
  88             return;
  89         }
  90 
  91         NSK_DISPLAY1("ClassLoad events are enabled only for thread '%s'", mainThreadName);
  92 
  93         disabledForOthers = 1;
  94 
  95         return;
  96     }
  97 
  98     if (disabledForOthers) {
  99         if (strcmp(threadName, mainThreadName) != 0) {
 100             success = 0;
 101             NSK_COMPLAIN1("ClassLoad event was erroneously generated for thread '%s'\n", threadName);
 102         }
 103     }
 104 
 105     /*


 124 Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
 125 #endif
 126 {
 127     jvmtiEnv* jvmti;
 128     jvmtiEventCallbacks eventCallbacks;
 129     JNIEnv* jni;
 130 
 131     if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
 132         return JNI_ERR;
 133 
 134     agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
 135 
 136     if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
 137         return NSK_FALSE;
 138 
 139     if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
 140         return JNI_ERR;
 141 
 142     memset(&eventCallbacks,0, sizeof(eventCallbacks));
 143     eventCallbacks.ClassLoad = classLoadHandler;
 144     if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))) ) {
 145         return JNI_ERR;
 146     }
 147 
 148     if (!(nsk_jvmti_aod_enableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD))) {
 149         return JNI_ERR;
 150     }
 151 
 152     NSK_DISPLAY1("%s: initialization was done\n", agentName);
 153 
 154     if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
 155         return JNI_ERR;
 156 
 157     return JNI_OK;
 158 }
 159 
 160 }


  65     if (!nsk_jvmti_aod_getClassName(jvmti, klass, loadedClassName)) {
  66         nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_CLASS_LOAD, 0, jvmti, jni);
  67         return;
  68     }
  69 
  70     NSK_DISPLAY2("Class '%s' was loaded by thread '%s'\n", loadedClassName, threadName);
  71 
  72     /*
  73      * When class FIRST_LOADED_CLASS was loaded try to disable events for all threads
  74      * except main target application thread
  75      */
  76     if (strcmp(loadedClassName, FIRST_LOADED_CLASS) == 0) {
  77         strcpy(mainThreadName, threadName);
  78 
  79         if (!nsk_jvmti_aod_disableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD)) {
  80             NSK_COMPLAIN0("Failed to disable events\n");
  81             nsk_aod_agentFinished(jni, agentName, 0);
  82             return;
  83         }
  84 
  85         if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, thread))) {
  86             NSK_COMPLAIN1("Failed to enable events for thread '%s'\n", mainThreadName);
  87             nsk_aod_agentFinished(jni, agentName, 0);
  88             return;
  89         }
  90 
  91         NSK_DISPLAY1("ClassLoad events are enabled only for thread '%s'", mainThreadName);
  92 
  93         disabledForOthers = 1;
  94 
  95         return;
  96     }
  97 
  98     if (disabledForOthers) {
  99         if (strcmp(threadName, mainThreadName) != 0) {
 100             success = 0;
 101             NSK_COMPLAIN1("ClassLoad event was erroneously generated for thread '%s'\n", threadName);
 102         }
 103     }
 104 
 105     /*


 124 Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved)
 125 #endif
 126 {
 127     jvmtiEnv* jvmti;
 128     jvmtiEventCallbacks eventCallbacks;
 129     JNIEnv* jni;
 130 
 131     if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))
 132         return JNI_ERR;
 133 
 134     agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
 135 
 136     if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)
 137         return NSK_FALSE;
 138 
 139     if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
 140         return JNI_ERR;
 141 
 142     memset(&eventCallbacks,0, sizeof(eventCallbacks));
 143     eventCallbacks.ClassLoad = classLoadHandler;
 144     if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
 145         return JNI_ERR;
 146     }
 147 
 148     if (!(nsk_jvmti_aod_enableEvent(jvmti, JVMTI_EVENT_CLASS_LOAD))) {
 149         return JNI_ERR;
 150     }
 151 
 152     NSK_DISPLAY1("%s: initialization was done\n", agentName);
 153 
 154     if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
 155         return JNI_ERR;
 156 
 157     return JNI_OK;
 158 }
 159 
 160 }
< prev index next >