< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted.cpp

Print this page
rev 52200 : [mq]: spaces


  60 {
  61     gGotEvent = JNI_FALSE;
  62 }
  63 
  64 #ifdef STATIC_BUILD
  65 JNIEXPORT jint JNICALL Agent_OnLoad_resexhausted(JavaVM *jvm, char *options, void *reserved) {
  66     return Agent_Initialize(jvm, options, reserved);
  67 }
  68 JNIEXPORT jint JNICALL Agent_OnAttach_resexhausted(JavaVM *jvm, char *options, void *reserved) {
  69     return Agent_Initialize(jvm, options, reserved);
  70 }
  71 JNIEXPORT jint JNI_OnLoad_resexhausted(JavaVM *jvm, char *options, void *reserved) {
  72     return JNI_VERSION_1_8;
  73 }
  74 #endif
  75 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved)
  76 {
  77     jvmtiEventCallbacks callbacks;
  78     jvmtiCapabilities capabilities;
  79 
  80     if ( ! NSK_VERIFY(nsk_jvmti_parseOptions(options)))
  81         return JNI_ERR;
  82 
  83     if ( ! NSK_VERIFY((gJvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL) )
  84         return JNI_ERR;
  85 
  86     memset(&capabilities, 0, sizeof(jvmtiCapabilities));
  87     capabilities.can_generate_resource_exhaustion_heap_events = 1;
  88     capabilities.can_generate_resource_exhaustion_threads_events = 1;
  89     if ( ! NSK_JVMTI_VERIFY(gJvmti->AddCapabilities(&capabilities)) )
  90         return JNI_ERR;
  91 
  92     memset((void *)&callbacks, 0, sizeof(jvmtiEventCallbacks));
  93     callbacks.ResourceExhausted = resourceExhausted;
  94     if ( ! NSK_JVMTI_VERIFY(gJvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))) )
  95         return JNI_ERR;
  96 
  97     if ( ! NSK_JVMTI_VERIFY(gJvmti->SetEventNotificationMode(JVMTI_ENABLE,
  98                                                              JVMTI_EVENT_RESOURCE_EXHAUSTED,
  99                                                              NULL) ) )
 100         return JNI_ERR;
 101 
 102     return JNI_OK;
 103 }
 104 
 105 }


  60 {
  61     gGotEvent = JNI_FALSE;
  62 }
  63 
  64 #ifdef STATIC_BUILD
  65 JNIEXPORT jint JNICALL Agent_OnLoad_resexhausted(JavaVM *jvm, char *options, void *reserved) {
  66     return Agent_Initialize(jvm, options, reserved);
  67 }
  68 JNIEXPORT jint JNICALL Agent_OnAttach_resexhausted(JavaVM *jvm, char *options, void *reserved) {
  69     return Agent_Initialize(jvm, options, reserved);
  70 }
  71 JNIEXPORT jint JNI_OnLoad_resexhausted(JavaVM *jvm, char *options, void *reserved) {
  72     return JNI_VERSION_1_8;
  73 }
  74 #endif
  75 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved)
  76 {
  77     jvmtiEventCallbacks callbacks;
  78     jvmtiCapabilities capabilities;
  79 
  80     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
  81         return JNI_ERR;
  82 
  83     if (!NSK_VERIFY((gJvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL))
  84         return JNI_ERR;
  85 
  86     memset(&capabilities, 0, sizeof(jvmtiCapabilities));
  87     capabilities.can_generate_resource_exhaustion_heap_events = 1;
  88     capabilities.can_generate_resource_exhaustion_threads_events = 1;
  89     if (!NSK_JVMTI_VERIFY(gJvmti->AddCapabilities(&capabilities)))
  90         return JNI_ERR;
  91 
  92     memset((void *)&callbacks, 0, sizeof(jvmtiEventCallbacks));
  93     callbacks.ResourceExhausted = resourceExhausted;
  94     if (!NSK_JVMTI_VERIFY(gJvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
  95         return JNI_ERR;
  96 
  97     if (!NSK_JVMTI_VERIFY(gJvmti->SetEventNotificationMode(JVMTI_ENABLE,
  98                                                            JVMTI_EVENT_RESOURCE_EXHAUSTED,
  99                                                            NULL)))
 100         return JNI_ERR;
 101 
 102     return JNI_OK;
 103 }
 104 
 105 }
< prev index next >