test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS203/hs203t004/hs203t004.cpp
changeset 57683 1cf884e437ea
parent 57629 7aba63ce3b3a
child 58679 9c3209ff7550
equal deleted inserted replaced
57681:41f2f2829a09 57683:1cf884e437ea
    48     if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) {
    48     if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &className, NULL))) {
    49         NSK_COMPLAIN0("#error Agent :: while getting classname.\n");
    49         NSK_COMPLAIN0("#error Agent :: while getting classname.\n");
    50         nsk_jvmti_agentFailed();
    50         nsk_jvmti_agentFailed();
    51     } else {
    51     } else {
    52         if (strcmp(className, CLASS_NAME) == 0) {
    52         if (strcmp(className, CLASS_NAME) == 0) {
    53             if (nsk_jvmti_enableNotification(jvmti_env, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL) == NSK_TRUE) {
    53             if (nsk_jvmti_enableNotification(jvmti_env, JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL)) {
    54                 NSK_DISPLAY0(" Agent :: notification enabled for COMPILED_METHOD_LOAD.\n");
    54                 NSK_DISPLAY0(" Agent :: notification enabled for COMPILED_METHOD_LOAD.\n");
    55                 if (!NSK_JVMTI_VERIFY(jvmti_env->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
    55                 if (!NSK_JVMTI_VERIFY(jvmti_env->GenerateEvents(JVMTI_EVENT_COMPILED_METHOD_LOAD))) {
    56                     NSK_COMPLAIN0("#error Agent :: occured while enabling compiled method events.\n");
    56                     NSK_COMPLAIN0("#error Agent :: occured while enabling compiled method events.\n");
    57                     nsk_jvmti_agentFailed();
    57                     nsk_jvmti_agentFailed();
    58                 }
    58                 }
   104                 NSK_DISPLAY2(" Agent :: Got CompiledMethodLoadEvent for class: %s, method: %s.\n", className, methodName);
   104                 NSK_DISPLAY2(" Agent :: Got CompiledMethodLoadEvent for class: %s, method: %s.\n", className, methodName);
   105                 NSK_DISPLAY0(" Agent :: redefining class.\n");
   105                 NSK_DISPLAY0(" Agent :: redefining class.\n");
   106 
   106 
   107                 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char));
   107                 nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char));
   108 
   108 
   109                 if (nsk_jvmti_redefineClass(jvmti_env, threadClass, fileName) == NSK_TRUE) {
   109                 if (nsk_jvmti_redefineClass(jvmti_env, threadClass, fileName)) {
   110                     NSK_DISPLAY0(" Agent :: Successfully redefined.\n");
   110                     NSK_DISPLAY0(" Agent :: Successfully redefined.\n");
   111                     redefineNumber++;
   111                     redefineNumber++;
   112                 } else {
   112                 } else {
   113                     NSK_COMPLAIN0("#error Agent :: Failed to redefine.\n");
   113                     NSK_COMPLAIN0("#error Agent :: Failed to redefine.\n");
   114                     nsk_jvmti_agentFailed();
   114                     nsk_jvmti_agentFailed();
   169         eventCallbacks.CompiledMethodLoad=callbackCompiledMethodLoad;
   169         eventCallbacks.CompiledMethodLoad=callbackCompiledMethodLoad;
   170         if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
   170         if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {
   171             NSK_COMPLAIN0("#error Agent :: occured while setting event callback.\n");
   171             NSK_COMPLAIN0("#error Agent :: occured while setting event callback.\n");
   172             return JNI_ERR;
   172             return JNI_ERR;
   173         }
   173         }
   174         if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL) == NSK_TRUE) {
   174         if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_CLASS_PREPARE, NULL)) {
   175             NSK_DISPLAY0(" Agent :: Notifications are enabled.\n");
   175             NSK_DISPLAY0(" Agent :: Notifications are enabled.\n");
   176         } else {
   176         } else {
   177             NSK_COMPLAIN0("#error Agent :: Error in enableing Notifications.\n");
   177             NSK_COMPLAIN0("#error Agent :: Error in enableing Notifications.\n");
   178             return JNI_ERR;
   178             return JNI_ERR;
   179         }
   179         }