< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk006/classfloadhk006.cpp
Print this page
rev 51942 : [mq]: refactor
*** 126,169 ****
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);
--- 126,165 ----
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);
*** 171,181 ****
(*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;
}
--- 167,177 ----
(*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;
}
*** 186,212 ****
jfieldID fieldID = NULL;
jobject obj = NULL;
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 NULL;
}
NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID);
NSK_DISPLAY1("Get object from static field: %s\n", fieldName);
! if (!NSK_JNI_VERIFY(jni, (obj =
! NSK_CPP_STUB3(GetStaticObjectField, jni, cls, fieldID)) != NULL)) {
nsk_jvmti_setFailStatus();
return NULL;
}
NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj);
NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj);
! if (!NSK_JNI_VERIFY(jni, (obj =
! NSK_CPP_STUB2(NewGlobalRef, jni, obj)) != NULL)) {
nsk_jvmti_setFailStatus();
return NULL;
}
NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj);
--- 182,206 ----
jfieldID fieldID = NULL;
jobject obj = NULL;
NSK_DISPLAY1("Find static field: %s\n", fieldName);
if (!NSK_JNI_VERIFY(jni, (fieldID =
! jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) {
nsk_jvmti_setFailStatus();
return NULL;
}
NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID);
NSK_DISPLAY1("Get object from static field: %s\n", fieldName);
! if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != NULL)) {
nsk_jvmti_setFailStatus();
return NULL;
}
NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj);
NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj);
! if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != NULL)) {
nsk_jvmti_setFailStatus();
return NULL;
}
NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj);
*** 221,232 ****
classDef.klass = klass;
classDef.class_byte_count = size;
classDef.class_bytes = bytes;
NSK_DISPLAY1("Redefine class: %s\n", className);
! if (!NSK_JVMTI_VERIFY(
! NSK_CPP_STUB3(RedefineClasses, jvmti, 1, &classDef))) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
NSK_DISPLAY1(" ... redefined with bytecode: %d bytes\n", (int)size);
--- 215,225 ----
classDef.klass = klass;
classDef.class_byte_count = size;
classDef.class_bytes = bytes;
NSK_DISPLAY1("Redefine class: %s\n", className);
! if (!NSK_JVMTI_VERIFY(jvmti->RedefineClasses(1, &classDef))) {
nsk_jvmti_setFailStatus();
return NSK_FALSE;
}
NSK_DISPLAY1(" ... redefined with bytecode: %d bytes\n", (int)size);
*** 248,258 ****
jclass debugeeClass = NULL;
NSK_DISPLAY0(">>> Obtain debuggee class\n");
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);
--- 241,251 ----
jclass debugeeClass = NULL;
NSK_DISPLAY0(">>> Obtain debuggee class\n");
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);
*** 307,321 ****
}
NSK_DISPLAY0(">>> Clean used data\n");
{
NSK_DISPLAY1("Delete global reference to tested class object: 0x%p\n", (void*)testedClass);
! NSK_CPP_STUB2(DeleteGlobalRef, jni, testedClass);
NSK_DISPLAY1("Deallocate redefined bytecode array: 0x%p\n", (void*)redefClassBytes);
! if (!NSK_JVMTI_VERIFY(
! NSK_CPP_STUB2(Deallocate, jvmti, redefClassBytes))) {
nsk_jvmti_setFailStatus();
}
}
}
--- 300,313 ----
}
NSK_DISPLAY0(">>> Clean used data\n");
{
NSK_DISPLAY1("Delete global reference to tested class object: 0x%p\n", (void*)testedClass);
! jni->DeleteGlobalRef(testedClass);
NSK_DISPLAY1("Deallocate redefined bytecode array: 0x%p\n", (void*)redefClassBytes);
! if (!NSK_JVMTI_VERIFY(jvmti->Deallocate(redefClassBytes))) {
nsk_jvmti_setFailStatus();
}
}
}
*** 345,355 ****
NSK_DISPLAY1("Check class_being_redefined: 0x%p\n", (void*)class_being_redefined);
if (class_being_redefined == NULL) {
NSK_COMPLAIN1("Unexpected NULL class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n",
(void*)class_being_redefined);
nsk_jvmti_setFailStatus();
! } else if (!NSK_CPP_STUB3(IsSameObject, jni, class_being_redefined, testedClass)) {
NSK_COMPLAIN2("Unexpected class_being_redefined in CLASS_FILE_LOAD_HOOK:\n"
"# got class: 0x%p\n"
"# expected same as: 0x%p\n",
(void*)class_being_redefined, (void*)testedClass);
nsk_jvmti_setFailStatus();
--- 337,347 ----
NSK_DISPLAY1("Check class_being_redefined: 0x%p\n", (void*)class_being_redefined);
if (class_being_redefined == NULL) {
NSK_COMPLAIN1("Unexpected NULL class_being_redefined in CLASS_FILE_LOAD_HOOK: 0x%p\n",
(void*)class_being_redefined);
nsk_jvmti_setFailStatus();
! } else if (!jni->IsSameObject(class_being_redefined, testedClass)) {
NSK_COMPLAIN2("Unexpected class_being_redefined in CLASS_FILE_LOAD_HOOK:\n"
"# got class: 0x%p\n"
"# expected same as: 0x%p\n",
(void*)class_being_redefined, (void*)testedClass);
nsk_jvmti_setFailStatus();
*** 395,406 ****
jvmtiCapabilities caps;
memset(&caps, 0, sizeof(caps));
caps.can_generate_all_class_hook_events = 1;
caps.can_redefine_classes = 1;
! if (!NSK_JVMTI_VERIFY(
! NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
return JNI_ERR;
}
}
NSK_DISPLAY0(" ... added\n");
--- 387,397 ----
jvmtiCapabilities caps;
memset(&caps, 0, sizeof(caps));
caps.can_generate_all_class_hook_events = 1;
caps.can_redefine_classes = 1;
! if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
return JNI_ERR;
}
}
NSK_DISPLAY0(" ... added\n");
*** 409,420 ****
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");
--- 400,410 ----
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 >