< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk004/classfloadhk004.cpp
Print this page
rev 51942 : [mq]: refactor
*** 59,102 ****
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);
--- 59,98 ----
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);
*** 104,114 ****
(*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;
}
--- 100,110 ----
(*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;
}
*** 127,137 ****
{
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);
--- 123,133 ----
{
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);
*** 269,280 ****
{
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");
--- 265,275 ----
{
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");
*** 283,294 ****
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");
--- 278,288 ----
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 >