test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/hotswap/HS103/hs103t002/hs103t002.cpp
changeset 52184 672bc2213cef
parent 51774 79dc492c00ab
child 52284 1f402d1f630f
equal deleted inserted replaced
52183:e3c221bc1711 52184:672bc2213cef
    55   jmethodID setRedefinitionFailed;
    55   jmethodID setRedefinitionFailed;
    56 
    56 
    57   testClass = jni->FindClass(MAIN_CLASS);
    57   testClass = jni->FindClass(MAIN_CLASS);
    58 
    58 
    59   if (!NSK_JNI_VERIFY(jni, (
    59   if (!NSK_JNI_VERIFY(jni, (
    60     setRedefinitionFailed = NSK_CPP_STUB4(GetStaticMethodID, jni,
    60     setRedefinitionFailed = jni->GetStaticMethodID(testClass, "setRedefinitionFailed", "()V")) != NULL))
    61                         testClass, "setRedefinitionFailed", "()V")) != NULL))
       
    62   {
    61   {
    63     NSK_CPP_STUB2(FatalError, jni,
    62     jni->FatalError("TEST FAILED: while getting setRedefinitionFailed()\n");
    64                 "TEST FAILED: while getting setRedefinitionFailed()\n");
       
    65   }
    63   }
    66 
    64 
    67   if (!NSK_JNI_VERIFY(jni, (
    65   if (!NSK_JNI_VERIFY(jni, (
    68     setRedefinitionDone = NSK_CPP_STUB4(GetStaticMethodID, jni,
    66     setRedefinitionDone = jni->GetStaticMethodID(testClass, "setRedefinitionDone", "()V")) != NULL))
    69                 testClass, "setRedefinitionDone", "()V")) != NULL))
       
    70   {
    67   {
    71     NSK_CPP_STUB2(FatalError, jni,
    68     jni->FatalError("TEST FAILED: while getting setRedefinitionDone()\n");
    72         "TEST FAILED: while getting setRedefinitionDone()\n");
       
    73   }
    69   }
    74 
    70 
    75   nsk_printf("doRedefineInNativeThread\n");
    71   nsk_printf("doRedefineInNativeThread\n");
    76   cla = jni->FindClass(SEARCH_NAME);
    72   cla = jni->FindClass(SEARCH_NAME);
    77   nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char));
    73   nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char));
    80     if ( nsk_jvmti_redefineClass(jvmti, cla,fileName) == NSK_TRUE) {
    76     if ( nsk_jvmti_redefineClass(jvmti, cla,fileName) == NSK_TRUE) {
    81       nsk_printf("\nMyClass :: Successfully redefined..\n");
    77       nsk_printf("\nMyClass :: Successfully redefined..\n");
    82     } else {
    78     } else {
    83       nsk_printf("\nMyClass :: Failed to redefine ..\n");
    79       nsk_printf("\nMyClass :: Failed to redefine ..\n");
    84 
    80 
    85       if (!NSK_JNI_VERIFY_VOID(jni, NSK_CPP_STUB3(CallStaticVoidMethod, jni,
    81       if (!NSK_JNI_VERIFY_VOID(jni, jni->CallStaticVoidMethod(testClass, setRedefinitionFailed)))
    86                                    testClass, setRedefinitionFailed)))
       
    87       {
    82       {
    88          NSK_CPP_STUB2(FatalError, jni,
    83          jni->FatalError("TEST FAILED: while calling setRedefinitionFailed()\n");
    89                 "TEST FAILED: while calling setRedefinitionFailed()\n");
       
    90       }
    84       }
    91     }
    85     }
    92   }
    86   }
    93 
    87 
    94   if (!NSK_JNI_VERIFY_VOID(jni, NSK_CPP_STUB3(CallStaticVoidMethod, jni,
    88   if (!NSK_JNI_VERIFY_VOID(jni, jni->CallStaticVoidMethod(testClass, setRedefinitionDone)))
    95                            testClass, setRedefinitionDone)))
       
    96   {
    89   {
    97     NSK_CPP_STUB2(FatalError, jni,
    90     jni->FatalError("TEST FAILED: while calling setRedefinitionDone()\n");
    98         "TEST FAILED: while calling setRedefinitionDone()\n");
       
    99   }
    91   }
   100 
    92 
   101   nsk_printf(" All 30 redefinitions are done..\n");
    93   nsk_printf(" All 30 redefinitions are done..\n");
   102 }
    94 }
   103 
    95 
   148   nsk_printf("hs103t002_startAgentThread\n");
   140   nsk_printf("hs103t002_startAgentThread\n");
   149 
   141 
   150   name = jni->NewStringUTF(threadName);
   142   name = jni->NewStringUTF(threadName);
   151   clas = jni->FindClass("java/lang/Thread");
   143   clas = jni->FindClass("java/lang/Thread");
   152 
   144 
   153   if (!NSK_JNI_VERIFY(jni, (method = NSK_CPP_STUB4(GetMethodID,
   145   if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(clas, "<init>", "(Ljava/lang/String;)V")) != NULL)) {
   154             jni, clas, "<init>","(Ljava/lang/String;)V")) != NULL)) {
   146     jni->FatalError("failed to get ID for the java method\n");
   155     NSK_CPP_STUB2(FatalError, jni,
       
   156             "failed to get ID for the java method\n");
       
   157   }
   147   }
   158 
   148 
   159   thread = (jthread) jni->NewObject(clas,method,name);
   149   thread = (jthread) jni->NewObject(clas,method,name);
   160   testAgentThread = jni->NewGlobalRef(thread);
   150   testAgentThread = jni->NewGlobalRef(thread);
   161   err = JVMTI_ERROR_NONE;
   151   err = JVMTI_ERROR_NONE;