< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t003/hs203t003.cpp
Print this page
rev 52050 : [mq]: refactor
*** 58,81 ****
char * className;
char * generic;
redefineNumber=0;
className=NULL;
generic=NULL;
! if ( ! NSK_JVMTI_VERIFY ( NSK_CPP_STUB4(GetClassSignature,
! jvmti_env, klass, &className, &generic) ) ) {
nsk_printf("#error Agent :: while getting classname Signature.\n");
nsk_jvmti_agentFailed();
} else {
if (strcmp(className,CLASS_NAME) == 0) {
jfieldID field;
/* get the field id and set watch on that .*/
! if (! NSK_JNI_VERIFY(jni, (field = NSK_CPP_STUB4(GetFieldID,
! jni, klass, FIELDNAME, TYPE)) != NULL) ) {
nsk_printf(" Agent :: (*JNI)->GetFieldID(jni, ... ) returns `null`.\n");
nsk_jvmti_agentFailed();
! } else if ( ! NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetFieldAccessWatch,
! jvmti_env, klass, field) ) ) {
nsk_printf("#error Agent :: occured while jvmti->SetFieldAccessWatch(... ) .\n");
nsk_jvmti_agentFailed();
}
}
}
--- 58,78 ----
char * className;
char * generic;
redefineNumber=0;
className=NULL;
generic=NULL;
! if ( ! NSK_JVMTI_VERIFY (jvmti_env->GetClassSignature(klass, &className, &generic) ) ) {
nsk_printf("#error Agent :: while getting classname Signature.\n");
nsk_jvmti_agentFailed();
} else {
if (strcmp(className,CLASS_NAME) == 0) {
jfieldID field;
/* get the field id and set watch on that .*/
! if (! NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, FIELDNAME, TYPE)) != NULL) ) {
nsk_printf(" Agent :: (*JNI)->GetFieldID(jni, ... ) returns `null`.\n");
nsk_jvmti_agentFailed();
! } else if ( ! NSK_JVMTI_VERIFY(jvmti_env->SetFieldAccessWatch(klass, field) ) ) {
nsk_printf("#error Agent :: occured while jvmti->SetFieldAccessWatch(... ) .\n");
nsk_jvmti_agentFailed();
}
}
}
*** 94,104 ****
if (redefineCnt < 10) {
redefineCnt++;
return;
}
redefineNumber=0;
! if (! NSK_JNI_VERIFY(jni, (clas = NSK_CPP_STUB2(FindClass, jni, SEARCH_NAME)) != NULL) ) {
nsk_printf(" Agent :: (*JNI)->FindClass(jni, %s) returns `null`.\n",SEARCH_NAME);
nsk_jvmti_agentFailed();
} else {
nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName,
sizeof(fileName)/sizeof(char));
--- 91,101 ----
if (redefineCnt < 10) {
redefineCnt++;
return;
}
redefineNumber=0;
! if (! NSK_JNI_VERIFY(jni, (clas = jni->FindClass(SEARCH_NAME)) != NULL) ) {
nsk_printf(" Agent :: (*JNI)->FindClass(jni, %s) returns `null`.\n",SEARCH_NAME);
nsk_jvmti_agentFailed();
} else {
nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName,
sizeof(fileName)/sizeof(char));
*** 107,117 ****
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: Redefined.\n");
nsk_printf(" Agent :: Suspendeding thread.\n");
/* pop the current working frame. */
! if ( ! NSK_JVMTI_VERIFY( NSK_CPP_STUB2(SuspendThread, jvmti_env, thread) ) ) {
nsk_printf("#error Agent :: occured suspending Thread.\n");
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: Succeded in suspending.\n");
}
--- 104,114 ----
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: Redefined.\n");
nsk_printf(" Agent :: Suspendeding thread.\n");
/* pop the current working frame. */
! if ( ! NSK_JVMTI_VERIFY(jvmti_env->SuspendThread(thread) ) ) {
nsk_printf("#error Agent :: occured suspending Thread.\n");
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: Succeded in suspending.\n");
}
*** 129,140 ****
JNIEXPORT jint JNI_OnLoad_hs203t003(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
! if ( ! NSK_VERIFY ( JNI_OK == NSK_CPP_STUB3(GetEnv, vm,
! (void **)&jvmti, JVMTI_VERSION_1_1) ) ) {
nsk_printf(" Agent :: Could not load JVMTI interface.\n");
return JNI_ERR;
} else {
jvmtiCapabilities caps;
jvmtiEventCallbacks eventCallbacks;
--- 126,136 ----
JNIEXPORT jint JNI_OnLoad_hs203t003(JavaVM *jvm, char *options, void *reserved) {
return JNI_VERSION_1_8;
}
#endif
jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
! if ( ! NSK_VERIFY ( JNI_OK == vm->GetEnv((void **)&jvmti, JVMTI_VERSION_1_1) ) ) {
nsk_printf(" Agent :: Could not load JVMTI interface.\n");
return JNI_ERR;
} else {
jvmtiCapabilities caps;
jvmtiEventCallbacks eventCallbacks;
*** 146,165 ****
caps.can_redefine_classes = 1;
caps.can_suspend=1;
caps.can_pop_frame=1;
caps.can_generate_all_class_hook_events=1;
caps.can_generate_field_access_events=1;
! if (! NSK_JVMTI_VERIFY ( NSK_CPP_STUB2(AddCapabilities, jvmti, &caps) )) {
nsk_printf("#error Agent :: while adding capabilities.\n");
return JNI_ERR;
}
memset(&eventCallbacks, 0, sizeof(eventCallbacks));
eventCallbacks.ClassPrepare =callbackClassPrepare;
eventCallbacks.FieldAccess= callbackFieldAccess;
! if (!NSK_JVMTI_VERIFY(
! NSK_CPP_STUB3(SetEventCallbacks, jvmti,
! &eventCallbacks, sizeof(eventCallbacks)))) {
nsk_printf("#error Agent :: while setting event callbacks.\n");
return JNI_ERR;
}
if ( ( nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL)
== NSK_TRUE ) &&
--- 142,159 ----
caps.can_redefine_classes = 1;
caps.can_suspend=1;
caps.can_pop_frame=1;
caps.can_generate_all_class_hook_events=1;
caps.can_generate_field_access_events=1;
! if (! NSK_JVMTI_VERIFY (jvmti->AddCapabilities(&caps) )) {
nsk_printf("#error Agent :: while adding capabilities.\n");
return JNI_ERR;
}
memset(&eventCallbacks, 0, sizeof(eventCallbacks));
eventCallbacks.ClassPrepare =callbackClassPrepare;
eventCallbacks.FieldAccess= callbackFieldAccess;
! if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
nsk_printf("#error Agent :: while setting event callbacks.\n");
return JNI_ERR;
}
if ( ( nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL)
== NSK_TRUE ) &&
*** 179,189 ****
jclass clas,
jthread thread) {
jboolean retvalue;
jint state;
retvalue = JNI_FALSE;
! if ( ! NSK_JVMTI_VERIFY( NSK_CPP_STUB3(GetThreadState, jvmti, thread, &state) ) ) {
nsk_printf(" Agent :: Error while getting thread state.\n");
nsk_jvmti_agentFailed();
} else {
if ( state & JVMTI_THREAD_STATE_SUSPENDED) {
retvalue = JNI_TRUE;
--- 173,183 ----
jclass clas,
jthread thread) {
jboolean retvalue;
jint state;
retvalue = JNI_FALSE;
! if ( ! NSK_JVMTI_VERIFY(jvmti->GetThreadState(thread, &state) ) ) {
nsk_printf(" Agent :: Error while getting thread state.\n");
nsk_jvmti_agentFailed();
} else {
if ( state & JVMTI_THREAD_STATE_SUSPENDED) {
retvalue = JNI_TRUE;
*** 197,218 ****
jclass clas,
jthread thread) {
jboolean retvalue;
jint state;
retvalue = JNI_FALSE;
! if ( ! NSK_JVMTI_VERIFY( NSK_CPP_STUB3(GetThreadState, jvmti, thread, &state) ) ) {
nsk_printf(" Agent :: Error while getting thread state.\n");
nsk_jvmti_agentFailed();
} else {
if ( state & JVMTI_THREAD_STATE_SUSPENDED) {
! if ( ! NSK_JVMTI_VERIFY ( NSK_CPP_STUB2( PopFrame, jvmti, thread) ) ) {
nsk_printf("#error Agent :: while poping thread's frame.\n");
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: poped thread frame.\n");
! if ( ! NSK_JVMTI_VERIFY ( NSK_CPP_STUB4 (SetEventNotificationMode, jvmti,
! JVMTI_DISABLE, JVMTI_EVENT_FIELD_ACCESS, NULL) ) ) {
nsk_printf("#error Agent :: failed to disable notification JVMTI_EVENT_FIELD ACCESS.\n");
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: Disabled notification JVMTI_EVENT_FIELD ACCESS. \n");
retvalue = JNI_TRUE;
--- 191,212 ----
jclass clas,
jthread thread) {
jboolean retvalue;
jint state;
retvalue = JNI_FALSE;
! if ( ! NSK_JVMTI_VERIFY(jvmti->GetThreadState(thread, &state) ) ) {
nsk_printf(" Agent :: Error while getting thread state.\n");
nsk_jvmti_agentFailed();
} else {
if ( state & JVMTI_THREAD_STATE_SUSPENDED) {
! if ( ! NSK_JVMTI_VERIFY (jvmti->PopFrame(thread) ) ) {
nsk_printf("#error Agent :: while poping thread's frame.\n");
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: poped thread frame.\n");
! if ( ! NSK_JVMTI_VERIFY (
! jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_FIELD_ACCESS, NULL) ) ) {
nsk_printf("#error Agent :: failed to disable notification JVMTI_EVENT_FIELD ACCESS.\n");
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: Disabled notification JVMTI_EVENT_FIELD ACCESS. \n");
retvalue = JNI_TRUE;
*** 230,240 ****
Java_nsk_jvmti_scenarios_hotswap_HS203_hs203t003_hs203t003_resumeThread(JNIEnv * jni,
jclass clas,
jthread thread) {
jboolean retvalue;
retvalue = JNI_FALSE;
! if ( !NSK_JVMTI_VERIFY( NSK_CPP_STUB2 ( ResumeThread, jvmti, thread)) ) {
nsk_printf("#error Agent :: while resuming thread.\n");
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: Thread resumed.\n");
retvalue= JNI_TRUE;
--- 224,234 ----
Java_nsk_jvmti_scenarios_hotswap_HS203_hs203t003_hs203t003_resumeThread(JNIEnv * jni,
jclass clas,
jthread thread) {
jboolean retvalue;
retvalue = JNI_FALSE;
! if ( !NSK_JVMTI_VERIFY(jvmti->ResumeThread(thread)) ) {
nsk_printf("#error Agent :: while resuming thread.\n");
nsk_jvmti_agentFailed();
} else {
nsk_printf(" Agent :: Thread resumed.\n");
retvalue= JNI_TRUE;
< prev index next >