test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass009/redefclass009.cpp
changeset 52642 9cfc8b0c45fd
parent 51870 cdfabab3413f
child 52809 7edc56620d42
equal deleted inserted replaced
52641:09a3f379b927 52642:9cfc8b0c45fd
   112 #endif
   112 #endif
   113 jint  Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
   113 jint  Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
   114     jint res;
   114     jint res;
   115     jvmtiError err;
   115     jvmtiError err;
   116 
   116 
   117     if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
   117     res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
       
   118     if (res != JNI_OK) {
   118         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
   119         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
   119         return JNI_ERR;
   120         return JNI_ERR;
   120     }
   121     }
   121 
   122 
   122     err = jvmti->GetPotentialCapabilities(&caps);
   123     err = jvmti->GetPotentialCapabilities(&caps);
   179                 methodsInfo[i].m_name, methodsInfo[i].m_sign);
   180                 methodsInfo[i].m_name, methodsInfo[i].m_sign);
   180             return STATUS_FAILED;
   181             return STATUS_FAILED;
   181         }
   182         }
   182 
   183 
   183         /* get the LocalVariableTable attribute */
   184         /* get the LocalVariableTable attribute */
   184         if ((err = (jvmti->GetLocalVariableTable(methodsInfo[i].mid,
   185         err = jvmti->GetLocalVariableTable(methodsInfo[i].mid, &count, &lv_table);
   185                 &count, &lv_table))) != JVMTI_ERROR_NONE) {
   186         if (err != JVMTI_ERROR_NONE) {
   186             printf("%s: Failed to call GetLocalVariableTable(): error=%d: %s\n",
   187             printf("%s: Failed to call GetLocalVariableTable(): error=%d: %s\n",
   187                 __FILE__, err, TranslateError(err));
   188                 __FILE__, err, TranslateError(err));
   188             printf("\tfor the%s%s method \"%s\", signature \"%s\"\n\n",
   189             printf("\tfor the%s%s method \"%s\", signature \"%s\"\n\n",
   189                 full?" ":" original ", methodsInfo[i].inst?"instance":"static",
   190                 full?" ":" original ", methodsInfo[i].inst?"instance":"static",
   190                 methodsInfo[i].m_name, methodsInfo[i].m_sign);
   191                 methodsInfo[i].m_name, methodsInfo[i].m_sign);
   264     classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
   265     classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
   265 
   266 
   266     if (vrb)
   267     if (vrb)
   267         printf("\n>>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
   268         printf("\n>>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
   268             classDef.class_byte_count);
   269             classDef.class_byte_count);
   269     if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
   270     err = jvmti->RedefineClasses(1, &classDef);
       
   271     if (err != JVMTI_ERROR_NONE) {
   270         printf("%s: Failed to call RedefineClasses(): error=%d: %s\n",
   272         printf("%s: Failed to call RedefineClasses(): error=%d: %s\n",
   271             __FILE__, err, TranslateError(err));
   273             __FILE__, err, TranslateError(err));
   272         printf("\tFor more info about this error see the JVMTI spec.\n");
   274         printf("\tFor more info about this error see the JVMTI spec.\n");
   273         return JNI_ERR;
   275         return JNI_ERR;
   274     }
   276     }