< prev index next >

src/hotspot/share/prims/jvmtiRedefineClasses.cpp

Print this page




1214     // Do the validity checks in compare_and_normalize_class_versions()
1215     // before verifying the byte codes. By doing these checks first, we
1216     // limit the number of functions that require redirection from
1217     // the_class to scratch_class. In particular, we don't have to
1218     // modify JNI GetSuperclass() and thus won't change its performance.
1219     jvmtiError res = compare_and_normalize_class_versions(the_class,
1220                        scratch_class);
1221     if (res != JVMTI_ERROR_NONE) {
1222       return res;
1223     }
1224 
1225     // verify what the caller passed us
1226     {
1227       // The bug 6214132 caused the verification to fail.
1228       // Information about the_class and scratch_class is temporarily
1229       // recorded into jvmtiThreadState. This data is used to redirect
1230       // the_class to scratch_class in the JVM_* functions called by the
1231       // verifier. Please, refer to jvmtiThreadState.hpp for the detailed
1232       // description.
1233       RedefineVerifyMark rvm(the_class, scratch_class, state);
1234       Verifier::verify(
1235         scratch_class, Verifier::ThrowException, true, THREAD);
1236     }
1237 
1238     if (HAS_PENDING_EXCEPTION) {
1239       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
1240       log_info(redefine, class, load, exceptions)("verify_byte_codes exception: '%s'", ex_name->as_C_string());
1241       CLEAR_PENDING_EXCEPTION;
1242       if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
1243         return JVMTI_ERROR_OUT_OF_MEMORY;
1244       } else {
1245         // tell the caller the bytecodes are bad
1246         return JVMTI_ERROR_FAILS_VERIFICATION;
1247       }
1248     }
1249 
1250     res = merge_cp_and_rewrite(the_class, scratch_class, THREAD);
1251     if (HAS_PENDING_EXCEPTION) {
1252       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
1253       log_info(redefine, class, load, exceptions)("merge_cp_and_rewrite exception: '%s'", ex_name->as_C_string());
1254       CLEAR_PENDING_EXCEPTION;
1255       if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
1256         return JVMTI_ERROR_OUT_OF_MEMORY;
1257       } else {
1258         return JVMTI_ERROR_INTERNAL;
1259       }
1260     }
1261 
1262     if (VerifyMergedCPBytecodes) {
1263       // verify what we have done during constant pool merging
1264       {
1265         RedefineVerifyMark rvm(the_class, scratch_class, state);
1266         Verifier::verify(scratch_class, Verifier::ThrowException, true, THREAD);
1267       }
1268 
1269       if (HAS_PENDING_EXCEPTION) {
1270         Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
1271         log_info(redefine, class, load, exceptions)
1272           ("verify_byte_codes post merge-CP exception: '%s'", ex_name->as_C_string());
1273         CLEAR_PENDING_EXCEPTION;
1274         if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
1275           return JVMTI_ERROR_OUT_OF_MEMORY;
1276         } else {
1277           // tell the caller that constant pool merging screwed up
1278           return JVMTI_ERROR_INTERNAL;
1279         }
1280       }
1281     }
1282 
1283     Rewriter::rewrite(scratch_class, THREAD);
1284     if (!HAS_PENDING_EXCEPTION) {
1285       scratch_class->link_methods(THREAD);
1286     }




1214     // Do the validity checks in compare_and_normalize_class_versions()
1215     // before verifying the byte codes. By doing these checks first, we
1216     // limit the number of functions that require redirection from
1217     // the_class to scratch_class. In particular, we don't have to
1218     // modify JNI GetSuperclass() and thus won't change its performance.
1219     jvmtiError res = compare_and_normalize_class_versions(the_class,
1220                        scratch_class);
1221     if (res != JVMTI_ERROR_NONE) {
1222       return res;
1223     }
1224 
1225     // verify what the caller passed us
1226     {
1227       // The bug 6214132 caused the verification to fail.
1228       // Information about the_class and scratch_class is temporarily
1229       // recorded into jvmtiThreadState. This data is used to redirect
1230       // the_class to scratch_class in the JVM_* functions called by the
1231       // verifier. Please, refer to jvmtiThreadState.hpp for the detailed
1232       // description.
1233       RedefineVerifyMark rvm(the_class, scratch_class, state);
1234       Verifier::verify(scratch_class, true, THREAD);

1235     }
1236 
1237     if (HAS_PENDING_EXCEPTION) {
1238       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
1239       log_info(redefine, class, load, exceptions)("verify_byte_codes exception: '%s'", ex_name->as_C_string());
1240       CLEAR_PENDING_EXCEPTION;
1241       if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
1242         return JVMTI_ERROR_OUT_OF_MEMORY;
1243       } else {
1244         // tell the caller the bytecodes are bad
1245         return JVMTI_ERROR_FAILS_VERIFICATION;
1246       }
1247     }
1248 
1249     res = merge_cp_and_rewrite(the_class, scratch_class, THREAD);
1250     if (HAS_PENDING_EXCEPTION) {
1251       Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
1252       log_info(redefine, class, load, exceptions)("merge_cp_and_rewrite exception: '%s'", ex_name->as_C_string());
1253       CLEAR_PENDING_EXCEPTION;
1254       if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
1255         return JVMTI_ERROR_OUT_OF_MEMORY;
1256       } else {
1257         return JVMTI_ERROR_INTERNAL;
1258       }
1259     }
1260 
1261     if (VerifyMergedCPBytecodes) {
1262       // verify what we have done during constant pool merging
1263       {
1264         RedefineVerifyMark rvm(the_class, scratch_class, state);
1265         Verifier::verify(scratch_class, true, THREAD);
1266       }
1267 
1268       if (HAS_PENDING_EXCEPTION) {
1269         Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
1270         log_info(redefine, class, load, exceptions)
1271           ("verify_byte_codes post merge-CP exception: '%s'", ex_name->as_C_string());
1272         CLEAR_PENDING_EXCEPTION;
1273         if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
1274           return JVMTI_ERROR_OUT_OF_MEMORY;
1275         } else {
1276           // tell the caller that constant pool merging screwed up
1277           return JVMTI_ERROR_INTERNAL;
1278         }
1279       }
1280     }
1281 
1282     Rewriter::rewrite(scratch_class, THREAD);
1283     if (!HAS_PENDING_EXCEPTION) {
1284       scratch_class->link_methods(THREAD);
1285     }


< prev index next >