test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS202/hs202t002/hs202t002.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 53518 2181425e0460
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    62             jclass cls;
    62             jclass cls;
    63             char fileName[512];
    63             char fileName[512];
    64             nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName,
    64             nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName,
    65                                   sizeof(fileName)/sizeof(char));
    65                                   sizeof(fileName)/sizeof(char));
    66             jvmti_env->GetMethodDeclaringClass(method, &cls);
    66             jvmti_env->GetMethodDeclaringClass(method, &cls);
    67             if (nsk_jvmti_redefineClass(jvmti_env, cls,fileName) == NSK_TRUE) {
    67             if (nsk_jvmti_redefineClass(jvmti_env, cls,fileName)) {
    68                 nsk_printf(" Agent:: redefine class success ..\n");
    68                 nsk_printf(" Agent:: redefine class success ..\n");
    69                 nsk_printf("Agent::SUSPENDING>> \n");
    69                 nsk_printf("Agent::SUSPENDING>> \n");
    70                 err=jvmti_env->SuspendThread(thread);
    70                 err=jvmti_env->SuspendThread(thread);
    71                 if (err == JVMTI_ERROR_NONE) {
    71                 if (err == JVMTI_ERROR_NONE) {
    72                   // we don't get here until we are resumed
    72                   // we don't get here until we are resumed
   101         return JNI_ERR;
   101         return JNI_ERR;
   102     } else {
   102     } else {
   103         jvmtiCapabilities caps;
   103         jvmtiCapabilities caps;
   104         jvmtiEventCallbacks eventCallbacks;
   104         jvmtiEventCallbacks eventCallbacks;
   105         memset(&caps, 0, sizeof(caps));
   105         memset(&caps, 0, sizeof(caps));
   106         if (nsk_jvmti_parseOptions(options) == NSK_FALSE) {
   106         if (!nsk_jvmti_parseOptions(options)) {
   107             nsk_printf("# error agent Failed to parse options \n");
   107             nsk_printf("# error agent Failed to parse options \n");
   108             return JNI_ERR;
   108             return JNI_ERR;
   109         }
   109         }
   110         caps.can_redefine_classes = 1;
   110         caps.can_redefine_classes = 1;
   111         caps.can_suspend = 1;
   111         caps.can_suspend = 1;
   117         rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks));
   117         rc=jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks));
   118         if (rc != JVMTI_ERROR_NONE) {
   118         if (rc != JVMTI_ERROR_NONE) {
   119             nsk_printf(" Agent:: Error occured while setting event callbacks \n");
   119             nsk_printf(" Agent:: Error occured while setting event callbacks \n");
   120             return JNI_ERR;
   120             return JNI_ERR;
   121         }
   121         }
   122         if (NSK_TRUE == nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_METHOD_EXIT, NULL)) {
   122         if (nsk_jvmti_enableNotification(jvmti,JVMTI_EVENT_METHOD_EXIT, NULL)) {
   123             nsk_printf(" Agent :: NOTIFICATIONS ARE ENABLED \n");
   123             nsk_printf(" Agent :: NOTIFICATIONS ARE ENABLED \n");
   124         } else {
   124         } else {
   125             nsk_printf(" Agent :: Error Enabling Notifications..");
   125             nsk_printf(" Agent :: Error Enabling Notifications..");
   126         }
   126         }
   127     }
   127     }
   158     jvmtiError err = JVMTI_ERROR_NONE;
   158     jvmtiError err = JVMTI_ERROR_NONE;
   159     jboolean retvalue = JNI_FALSE;
   159     jboolean retvalue = JNI_FALSE;
   160 
   160 
   161     // disable notifications before resuming thread
   161     // disable notifications before resuming thread
   162     // to avoid recursion on PopFrame issued reinvoke
   162     // to avoid recursion on PopFrame issued reinvoke
   163     if (NSK_TRUE == nsk_jvmti_disableNotification(jvmti,JVMTI_EVENT_METHOD_EXIT, NULL)) {
   163     if (nsk_jvmti_disableNotification(jvmti,JVMTI_EVENT_METHOD_EXIT, NULL)) {
   164         nsk_printf("Agent :: nsk_jvmti_disabled notifications..\n");
   164         nsk_printf("Agent :: nsk_jvmti_disabled notifications..\n");
   165     } else {
   165     } else {
   166         nsk_printf("Agent :: Failed to disable notifications..");
   166         nsk_printf("Agent :: Failed to disable notifications..");
   167         return JNI_FALSE;
   167         return JNI_FALSE;
   168     }
   168     }