< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk002/classfloadhk002.cpp

Print this page
rev 51942 : [mq]: refactor

*** 120,163 **** jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = ! NSK_CPP_STUB4(GetStaticFieldID, jni, cls, fieldName, fieldSig)) != NULL)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) ! NSK_CPP_STUB3(GetStaticObjectField, jni, cls, fieldID)) != NULL)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... got array object: 0x%p\n", (void*)array); ! if (!NSK_JNI_VERIFY(jni, (*size = ! NSK_CPP_STUB2(GetArrayLength, jni, array)) > 0)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... got array size: %d bytes\n", (int)*size); { jboolean isCopy; ! if (!NSK_JNI_VERIFY(jni, (elements = ! NSK_CPP_STUB3(GetByteArrayElements, jni, array, ! &isCopy)) != NULL)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } } NSK_DISPLAY1(" ... got elements list: 0x%p\n", (void*)elements); ! if (!NSK_JVMTI_VERIFY( ! NSK_CPP_STUB3(Allocate, jvmti, *size, bytes))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... created bytes array: 0x%p\n", (void*)*bytes); --- 120,159 ---- jbyte* elements; int i; NSK_DISPLAY1("Find static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (fieldID = ! jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) ! jni->GetStaticObjectField(cls, fieldID)) != NULL)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... got array object: 0x%p\n", (void*)array); ! if (!NSK_JNI_VERIFY(jni, (*size = jni->GetArrayLength(array)) > 0)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... got array size: %d bytes\n", (int)*size); { jboolean isCopy; ! if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } } NSK_DISPLAY1(" ... got elements list: 0x%p\n", (void*)elements); ! if (!NSK_JVMTI_VERIFY(jvmti->Allocate(*size, bytes))) { nsk_jvmti_setFailStatus(); return NSK_FALSE; } NSK_DISPLAY1(" ... created bytes array: 0x%p\n", (void*)*bytes);
*** 165,175 **** (*bytes)[i] = (unsigned char)elements[i]; } NSK_DISPLAY1(" ... copied bytecode: %d bytes\n", (int)*size); NSK_DISPLAY1("Release elements list: 0x%p\n", (void*)elements); ! NSK_TRACE(NSK_CPP_STUB4(ReleaseByteArrayElements, jni, array, elements, JNI_ABORT)); NSK_DISPLAY0(" ... released\n"); return NSK_TRUE; } --- 161,171 ---- (*bytes)[i] = (unsigned char)elements[i]; } NSK_DISPLAY1(" ... copied bytecode: %d bytes\n", (int)*size); NSK_DISPLAY1("Release elements list: 0x%p\n", (void*)elements); ! NSK_TRACE(jni->ReleaseByteArrayElements(array, elements, JNI_ABORT)); NSK_DISPLAY0(" ... released\n"); return NSK_TRUE; }
*** 188,198 **** { jclass debugeeClass = NULL; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = ! NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL)) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1(" ... found class: 0x%p\n", (void*)debugeeClass); --- 184,194 ---- { jclass debugeeClass = NULL; NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); if (!NSK_JNI_VERIFY(jni, (debugeeClass = ! jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) { nsk_jvmti_setFailStatus(); return; } NSK_DISPLAY1(" ... found class: 0x%p\n", (void*)debugeeClass);
*** 238,249 **** } NSK_DISPLAY0(">>> Clean used data\n"); { NSK_DISPLAY1("Deallocate bytecode array: 0x%p\n", (void*)origClassBytes); ! if (!NSK_JVMTI_VERIFY( ! NSK_CPP_STUB2(Deallocate, jvmti, origClassBytes))) { nsk_jvmti_setFailStatus(); } } } --- 234,244 ---- } NSK_DISPLAY0(">>> Clean used data\n"); { NSK_DISPLAY1("Deallocate bytecode array: 0x%p\n", (void*)origClassBytes); ! if (!NSK_JVMTI_VERIFY(jvmti->Deallocate(origClassBytes))) { nsk_jvmti_setFailStatus(); } } }
*** 316,327 **** { jvmtiCapabilities caps; memset(&caps, 0, sizeof(caps)); caps.can_generate_all_class_hook_events = 1; ! if (!NSK_JVMTI_VERIFY( ! NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) { return JNI_ERR; } } NSK_DISPLAY0(" ... added\n"); --- 311,321 ---- { jvmtiCapabilities caps; memset(&caps, 0, sizeof(caps)); caps.can_generate_all_class_hook_events = 1; ! if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) { return JNI_ERR; } } NSK_DISPLAY0(" ... added\n");
*** 330,341 **** jvmtiEventCallbacks callbacks; jint size = (jint)sizeof(callbacks); memset(&callbacks, 0, sizeof(callbacks)); callbacks.ClassFileLoadHook = callbackClassFileLoadHook; ! if (!NSK_JVMTI_VERIFY( ! NSK_CPP_STUB3(SetEventCallbacks, jvmti, &callbacks, size))) { return JNI_ERR; } } NSK_DISPLAY0(" ... set\n"); --- 324,334 ---- jvmtiEventCallbacks callbacks; jint size = (jint)sizeof(callbacks); memset(&callbacks, 0, sizeof(callbacks)); callbacks.ClassFileLoadHook = callbackClassFileLoadHook; ! if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, size))) { return JNI_ERR; } } NSK_DISPLAY0(" ... set\n");
< prev index next >