< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP02/ap02t001/ap02t001.cpp

Print this page
rev 52200 : [mq]: spaces


  49 static jlong timeout = 0;
  50 static int user_data = 0;
  51 static const char* TESTED_CLASS_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP02/ap02t001Exception;";
  52 static const jlong TESTED_CLASS_TAG = (jlong)1024;
  53 static jclass testedClass = NULL;
  54 
  55 jvmtiIterationControl JNICALL
  56 heapObjectCallback(jlong class_tag,
  57                    jlong size,
  58                    jlong* tag_ptr,
  59                    void* user_data) {
  60 
  61     if (class_tag == TESTED_CLASS_TAG) {
  62         obj_count++;
  63     }
  64 
  65     return JVMTI_ITERATION_CONTINUE;
  66 }
  67 
  68 jvmtiIterationControl JNICALL
  69 stackReferenceCallback( jvmtiHeapRootKind root_kind,
  70                         jlong     class_tag,
  71                         jlong     size,
  72                         jlong*    tag_ptr,
  73                         jlong     thread_tag,
  74                         jint      depth,
  75                         jmethodID method,
  76                         jint      slot,
  77                         void*     user_data) {
  78 
  79     if (class_tag == TESTED_CLASS_TAG) {
  80         obj_count++;
  81     }
  82 
  83     return JVMTI_ITERATION_CONTINUE;
  84 }
  85 
  86 /************************/
  87 
  88 JNIEXPORT void JNICALL
  89 Java_nsk_jvmti_scenarios_allocation_AP02_ap02t001_throwException( JNIEnv* jni,
  90                                                                   jclass cls,
  91                                                                   jclass exception_cls ) {
  92     jint result;
  93 
  94     result = jni->ThrowNew(exception_cls, "Got expected exception thrown from native code" );
  95     if (result != 0) {
  96         NSK_COMPLAIN1("throwException: Unable to throw exception in native code: %d\n\n", result );
  97         nsk_jvmti_setFailStatus();
  98     } else {
  99         NSK_DISPLAY0("throwException: ThrowNew returned success code: 0\n\n");
 100     }
 101 }
 102 
 103 static void runIterations (jvmtiEnv* jvmti, jclass testedClass, jint exp_count) {
 104     NSK_DISPLAY0("Calling IterateOverInstancesOfClass with filter JVMTI_HEAP_OBJECT_EITHER\n");
 105     obj_count = 0;
 106     if (!NSK_JVMTI_VERIFY(jvmti->IterateOverInstancesOfClass(testedClass,
 107                                                              JVMTI_HEAP_OBJECT_EITHER,
 108                                                              heapObjectCallback,
 109                                                              &user_data))) {
 110         nsk_jvmti_setFailStatus();
 111         return;
 112     }
 113 
 114     if (obj_count != exp_count) {
 115         nsk_jvmti_setFailStatus();
 116         NSK_COMPLAIN3(




  49 static jlong timeout = 0;
  50 static int user_data = 0;
  51 static const char* TESTED_CLASS_SIGNATURE = "Lnsk/jvmti/scenarios/allocation/AP02/ap02t001Exception;";
  52 static const jlong TESTED_CLASS_TAG = (jlong)1024;
  53 static jclass testedClass = NULL;
  54 
  55 jvmtiIterationControl JNICALL
  56 heapObjectCallback(jlong class_tag,
  57                    jlong size,
  58                    jlong* tag_ptr,
  59                    void* user_data) {
  60 
  61     if (class_tag == TESTED_CLASS_TAG) {
  62         obj_count++;
  63     }
  64 
  65     return JVMTI_ITERATION_CONTINUE;
  66 }
  67 
  68 jvmtiIterationControl JNICALL
  69 stackReferenceCallback(jvmtiHeapRootKind root_kind,
  70                        jlong     class_tag,
  71                        jlong     size,
  72                        jlong*    tag_ptr,
  73                        jlong     thread_tag,
  74                        jint      depth,
  75                        jmethodID method,
  76                        jint      slot,
  77                        void*     user_data) {
  78 
  79     if (class_tag == TESTED_CLASS_TAG) {
  80         obj_count++;
  81     }
  82 
  83     return JVMTI_ITERATION_CONTINUE;
  84 }
  85 
  86 /************************/
  87 
  88 JNIEXPORT void JNICALL
  89 Java_nsk_jvmti_scenarios_allocation_AP02_ap02t001_throwException(JNIEnv* jni,
  90                                                                  jclass cls,
  91                                                                  jclass exception_cls) {
  92     jint result;
  93 
  94     result = jni->ThrowNew(exception_cls, "Got expected exception thrown from native code");
  95     if (result != 0) {
  96         NSK_COMPLAIN1("throwException: Unable to throw exception in native code: %d\n\n", result);
  97         nsk_jvmti_setFailStatus();
  98     } else {
  99         NSK_DISPLAY0("throwException: ThrowNew returned success code: 0\n\n");
 100     }
 101 }
 102 
 103 static void runIterations (jvmtiEnv* jvmti, jclass testedClass, jint exp_count) {
 104     NSK_DISPLAY0("Calling IterateOverInstancesOfClass with filter JVMTI_HEAP_OBJECT_EITHER\n");
 105     obj_count = 0;
 106     if (!NSK_JVMTI_VERIFY(jvmti->IterateOverInstancesOfClass(testedClass,
 107                                                              JVMTI_HEAP_OBJECT_EITHER,
 108                                                              heapObjectCallback,
 109                                                              &user_data))) {
 110         nsk_jvmti_setFailStatus();
 111         return;
 112     }
 113 
 114     if (obj_count != exp_count) {
 115         nsk_jvmti_setFailStatus();
 116         NSK_COMPLAIN3(


< prev index next >