test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass004/redefclass004.cpp
changeset 52642 9cfc8b0c45fd
parent 51870 cdfabab3413f
equal deleted inserted replaced
52641:09a3f379b927 52642:9cfc8b0c45fd
    56 #endif
    56 #endif
    57 jint  Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
    57 jint  Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
    58     jint res;
    58     jint res;
    59     jvmtiError err;
    59     jvmtiError err;
    60 
    60 
    61     if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) {
    61     res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
       
    62     if (res != JNI_OK) {
    62         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
    63         printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res);
    63         return JNI_ERR;
    64         return JNI_ERR;
    64     }
    65     }
    65 
    66 
    66     err = jvmti->GetPotentialCapabilities(&caps);
    67     err = jvmti->GetPotentialCapabilities(&caps);
   113     classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
   114     classDef.class_bytes = (unsigned char *) env->GetByteArrayElements(classBytes, NULL);
   114 
   115 
   115     if (vrb == 1)
   116     if (vrb == 1)
   116         printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
   117         printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n",
   117             classDef.class_byte_count);
   118             classDef.class_byte_count);
   118     if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) {
   119     err = jvmti->RedefineClasses(1, &classDef);
       
   120     if (err != JVMTI_ERROR_NONE) {
   119         if (err == JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED) {
   121         if (err == JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED) {
   120             printf(
   122             printf(
   121                 "Warning: unrestrictedly redefinition of classes is not implemented,\n"
   123                 "Warning: unrestrictedly redefinition of classes is not implemented,\n"
   122                 "\tso the test has no results.\n");
   124                 "\tso the test has no results.\n");
   123             no_results = 1;
   125             no_results = 1;
   145     jlong longFld;
   147     jlong longFld;
   146     jstring stringObj;
   148     jstring stringObj;
   147     const char *strFld = NULL;
   149     const char *strFld = NULL;
   148 
   150 
   149 /* get value of new instance field "intComplNewFld" */
   151 /* get value of new instance field "intComplNewFld" */
   150     if ((fid = env->GetFieldID(redefCls, "intComplNewFld", "I")) == NULL) {
   152     fid = env->GetFieldID(redefCls, "intComplNewFld", "I");
       
   153     if (fid == NULL) {
   151         printf("%s: Failed to get the field ID for the field \"intComplNewFld\"\n",
   154         printf("%s: Failed to get the field ID for the field \"intComplNewFld\"\n",
   152             __FILE__);
   155             __FILE__);
   153         return STATUS_FAILED;
   156         return STATUS_FAILED;
   154     }
   157     }
   155     intFld = env->GetIntField(redefObj, fid);
   158     intFld = env->GetIntField(redefObj, fid);
   156 
   159 
   157 /* get value of new instance field "longComplNewFld" */
   160 /* get value of new instance field "longComplNewFld" */
   158     if ((fid = env->GetFieldID(redefCls, "longComplNewFld", "J")) == NULL) {
   161     fid = env->GetFieldID(redefCls, "longComplNewFld", "J");
       
   162     if (fid == NULL) {
   159         printf("%s: Failed to get the field ID for the field \"longComplNewFld\"\n",
   163         printf("%s: Failed to get the field ID for the field \"longComplNewFld\"\n",
   160             __FILE__);
   164             __FILE__);
   161         return STATUS_FAILED;
   165         return STATUS_FAILED;
   162     }
   166     }
   163     longFld = env->GetLongField(redefObj, fid);
   167     longFld = env->GetLongField(redefObj, fid);
   164 
   168 
   165 /* get value of new instance field "stringComplNewFld" */
   169 /* get value of new instance field "stringComplNewFld" */
   166     if ((fid = env->GetFieldID(redefCls, "stringComplNewFld", "Ljava/lang/String;")) == NULL) {
   170     fid = env->GetFieldID(redefCls, "stringComplNewFld", "Ljava/lang/String;");
       
   171     if (fid == NULL) {
   167         printf("%s: Failed to get the field ID for the field \"stringComplNewFld\"\n",
   172         printf("%s: Failed to get the field ID for the field \"stringComplNewFld\"\n",
   168             __FILE__);
   173             __FILE__);
   169         return STATUS_FAILED;
   174         return STATUS_FAILED;
   170     }
   175     }
   171     stringObj = (jstring) env->GetObjectField(redefObj, fid);
   176     stringObj = (jstring) env->GetObjectField(redefObj, fid);