@@ -2452,11 +2452,11 @@ void InstanceKlass::metaspace_pointers_do(MetaspaceClosure* it) {
24522452#endif
24532453#if INCLUDE_CDS
24542454 // For "old" classes with methods containing the jsr bytecode, the _methods array will
2455- // be rewritten during runtime (see Rewriter::rewrite_jsrs()). So setting the _methods to
2456- // be writable. The length check on the _methods is necessary because classes which
2457- // don't have any methods share the Universe::_the_empty_method_array which is in the RO region.
2458- if (_methods != nullptr && _methods-> length () > 0 &&
2459- ! can_be_verified_at_dumptime () && methods_contain_jsr_bytecode ()) {
2455+ // be rewritten during runtime (see Rewriter::rewrite_jsrs()) but they cannot be safely
2456+ // checked here with ByteCodeStream. All methods that can't be verified are made writable.
2457+ // The length check on the _methods is necessary because classes which don't have any
2458+ // methods share the Universe::_the_empty_method_array which is in the RO region.
2459+ if (_methods != nullptr && _methods-> length () > 0 && ! can_be_verified_at_dumptime ()) {
24602460 // To handle jsr bytecode, new Method* maybe stored into _methods
24612461 it->push (&_methods, MetaspaceClosure::_writable);
24622462 } else {
@@ -2697,21 +2697,6 @@ bool InstanceKlass::can_be_verified_at_dumptime() const {
26972697 }
26982698 return true ;
26992699}
2700-
2701- bool InstanceKlass::methods_contain_jsr_bytecode () const {
2702- Thread* thread = Thread::current ();
2703- for (int i = 0 ; i < _methods->length (); i++) {
2704- methodHandle m (thread, _methods->at (i));
2705- BytecodeStream bcs (m);
2706- while (!bcs.is_last_bytecode ()) {
2707- Bytecodes::Code opcode = bcs.next ();
2708- if (opcode == Bytecodes::_jsr || opcode == Bytecodes::_jsr_w) {
2709- return true ;
2710- }
2711- }
2712- }
2713- return false ;
2714- }
27152700#endif // INCLUDE_CDS
27162701
27172702#if INCLUDE_JVMTI
0 commit comments