diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 6b6d35ee026de..b522a3948b533 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -2452,11 +2452,11 @@ void InstanceKlass::metaspace_pointers_do(MetaspaceClosure* it) { #endif #if INCLUDE_CDS // For "old" classes with methods containing the jsr bytecode, the _methods array will - // be rewritten during runtime (see Rewriter::rewrite_jsrs()). So setting the _methods to - // be writable. The length check on the _methods is necessary because classes which - // don't have any methods share the Universe::_the_empty_method_array which is in the RO region. - if (_methods != nullptr && _methods->length() > 0 && - !can_be_verified_at_dumptime() && methods_contain_jsr_bytecode()) { + // be rewritten during runtime (see Rewriter::rewrite_jsrs()) but they cannot be safely + // checked here with ByteCodeStream. All methods that can't be verified are made writable. + // The length check on the _methods is necessary because classes which don't have any + // methods share the Universe::_the_empty_method_array which is in the RO region. + if (_methods != nullptr && _methods->length() > 0 && !can_be_verified_at_dumptime()) { // To handle jsr bytecode, new Method* maybe stored into _methods it->push(&_methods, MetaspaceClosure::_writable); } else { @@ -2697,21 +2697,6 @@ bool InstanceKlass::can_be_verified_at_dumptime() const { } return true; } - -bool InstanceKlass::methods_contain_jsr_bytecode() const { - Thread* thread = Thread::current(); - for (int i = 0; i < _methods->length(); i++) { - methodHandle m(thread, _methods->at(i)); - BytecodeStream bcs(m); - while (!bcs.is_last_bytecode()) { - Bytecodes::Code opcode = bcs.next(); - if (opcode == Bytecodes::_jsr || opcode == Bytecodes::_jsr_w) { - return true; - } - } - } - return false; -} #endif // INCLUDE_CDS #if INCLUDE_JVMTI diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index 45d65f273c866..daaa16f2059c3 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -1116,7 +1116,6 @@ class InstanceKlass: public Klass { void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS); void init_shared_package_entry(); bool can_be_verified_at_dumptime() const; - bool methods_contain_jsr_bytecode() const; void compute_has_loops_flag_for_methods(); #endif