diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index c678fa5e05819..01e35161efdd8 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -4092,31 +4092,29 @@ static Array* compute_transitive_interfaces(const InstanceKlass* void ClassFileParser::check_super_class_access(const InstanceKlass* this_klass, TRAPS) { assert(this_klass != nullptr, "invariant"); - const Klass* const super = this_klass->super(); + const InstanceKlass* const super = this_klass->java_super(); if (super != nullptr) { - const InstanceKlass* super_ik = InstanceKlass::cast(super); - if (super->is_final()) { - classfile_icce_error("class %s cannot inherit from final class %s", super_ik, THREAD); + classfile_icce_error("class %s cannot inherit from final class %s", super, THREAD); return; } - if (super_ik->is_sealed()) { + if (super->is_sealed()) { stringStream ss; ResourceMark rm(THREAD); - if (!super_ik->has_as_permitted_subclass(this_klass, ss)) { + if (!super->has_as_permitted_subclass(this_klass, ss)) { classfile_icce_error(ss.as_string(), THREAD); return; } } Reflection::VerifyClassAccessResults vca_result = - Reflection::verify_class_access(this_klass, InstanceKlass::cast(super), false); + Reflection::verify_class_access(this_klass, super, false); if (vca_result != Reflection::ACCESS_OK) { ResourceMark rm(THREAD); char* msg = Reflection::verify_class_access_msg(this_klass, - InstanceKlass::cast(super), + super, vca_result); // Names are all known to be < 64k so we know this formatted message is not excessively large. @@ -4218,7 +4216,7 @@ static void check_final_method_override(const InstanceKlass* this_klass, TRAPS) // skip supers that don't have final methods. if (k->has_final_method()) { // lookup a matching method in the super class hierarchy - super_m = InstanceKlass::cast(k)->lookup_method(name, signature); + super_m = k->lookup_method(name, signature); if (super_m == nullptr) { break; // didn't find any match; get out } diff --git a/src/hotspot/share/classfile/fieldLayoutBuilder.cpp b/src/hotspot/share/classfile/fieldLayoutBuilder.cpp index 21f47e3de10d9..d06f5dd96d177 100644 --- a/src/hotspot/share/classfile/fieldLayoutBuilder.cpp +++ b/src/hotspot/share/classfile/fieldLayoutBuilder.cpp @@ -316,7 +316,7 @@ void FieldLayout::reconstruct_layout(const InstanceKlass* ik, bool& has_instance block->set_offset(fs.offset()); all_fields->append(block); } - ik = ik->super() == nullptr ? nullptr : InstanceKlass::cast(ik->super()); + ik = ik->java_super() == nullptr ? nullptr : ik->java_super(); } assert(last_offset == -1 || last_offset > 0, "Sanity"); if (last_offset > 0 && diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 783ae9d35ba54..ae7432c9fcebe 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -1049,7 +1049,7 @@ bool SystemDictionary::check_shared_class_super_types(InstanceKlass* ik, Handle // load from the shared archive. if (ik->super() != nullptr) { - bool check_super = check_shared_class_super_type(ik, InstanceKlass::cast(ik->super()), + bool check_super = check_shared_class_super_type(ik, ik->java_super(), class_loader, true, CHECK_false); if (!check_super) { diff --git a/src/hotspot/share/classfile/vmClasses.cpp b/src/hotspot/share/classfile/vmClasses.cpp index 813926e51a223..9b9222268a61b 100644 --- a/src/hotspot/share/classfile/vmClasses.cpp +++ b/src/hotspot/share/classfile/vmClasses.cpp @@ -225,10 +225,10 @@ void vmClasses::resolve_shared_class(InstanceKlass* klass, ClassLoaderData* load } // add super and interfaces first - Klass* super = klass->super(); + InstanceKlass* super = klass->java_super(); if (super != nullptr && super->class_loader_data() == nullptr) { assert(super->is_instance_klass(), "Super should be instance klass"); - resolve_shared_class(InstanceKlass::cast(super), loader_data, domain, CHECK); + resolve_shared_class(super, loader_data, domain, CHECK); } Array* ifs = klass->local_interfaces(); diff --git a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp index 5e7f65aeec1e8..81e8a82c78d19 100644 --- a/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp +++ b/src/hotspot/share/jfr/instrumentation/jfrEventClassTransformer.cpp @@ -214,7 +214,7 @@ static bool annotation_value(const InstanceKlass* ik, const Symbol* annotation_t if (has_annotation(ik, annotation_type, default_value, value)) { return true; } - InstanceKlass* const super = InstanceKlass::cast(ik->super()); + InstanceKlass* const super = ik->java_super(); return super != nullptr && JdkJfrEvent::is_a(super) ? annotation_value(super, annotation_type, default_value, value) : false; } diff --git a/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp b/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp index 6a38553403d71..c9d79a23c2f98 100644 --- a/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp +++ b/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp @@ -76,7 +76,7 @@ const Symbol* EdgeUtils::field_name(const Edge& edge, jshort* modifiers) { } jfs.next(); } - ik = (const InstanceKlass*)ik->super(); + ik = ik->java_super(); } *modifiers = 0; return nullptr; diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index e4900249dbd0a..dbc3ebd9c6e37 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -2012,7 +2012,7 @@ C2V_VMENTRY_NULL(jobject, getInterfaces, (JNIEnv* env, jobject, ARGUMENT_PAIR(kl JVMCIObjectArray interfaces = JVMCIENV->new_HotSpotResolvedObjectTypeImpl_array(size, JVMCI_CHECK_NULL); for (int index = 0; index < size; index++) { JVMCIKlassHandle klass(THREAD); - Klass* k = iklass->local_interfaces()->at(index); + InstanceKlass* k = iklass->local_interfaces()->at(index); klass = k; JVMCIObject type = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL); JVMCIENV->put_object_at(interfaces, index, type); diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index dcec45ff4e224..a7641b9a54699 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -575,7 +575,7 @@ void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data, } void InstanceKlass::deallocate_interfaces(ClassLoaderData* loader_data, - const Klass* super_klass, + const InstanceKlass* super_klass, Array* local_interfaces, Array* transitive_interfaces) { // Only deallocate transitive interfaces if not empty, same as super class @@ -584,7 +584,7 @@ void InstanceKlass::deallocate_interfaces(ClassLoaderData* loader_data, if (ti != Universe::the_empty_instance_klass_array() && ti != local_interfaces) { // check that the interfaces don't come from super class Array* sti = (super_klass == nullptr) ? nullptr : - InstanceKlass::cast(super_klass)->transitive_interfaces(); + super_klass->transitive_interfaces(); if (ti != sti && ti != nullptr && !ti->is_shared()) { MetadataFactory::free_array(loader_data, ti); } @@ -677,7 +677,7 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) { } set_secondary_supers(nullptr, SECONDARY_SUPERS_BITMAP_EMPTY); - deallocate_interfaces(loader_data, super(), local_interfaces(), transitive_interfaces()); + deallocate_interfaces(loader_data, java_super(), local_interfaces(), transitive_interfaces()); set_transitive_interfaces(nullptr); set_local_interfaces(nullptr); @@ -942,7 +942,7 @@ bool InstanceKlass::link_class_impl(TRAPS) { JavaThread* jt = THREAD; // link super class before linking this class - Klass* super_klass = super(); + InstanceKlass* super_klass = java_super(); if (super_klass != nullptr) { if (super_klass->is_interface()) { // check if super class is an interface ResourceMark rm(THREAD); @@ -957,8 +957,7 @@ bool InstanceKlass::link_class_impl(TRAPS) { return false; } - InstanceKlass* ik_super = InstanceKlass::cast(super_klass); - ik_super->link_class_impl(CHECK_false); + super_klass->link_class_impl(CHECK_false); } // link all interfaces implemented by this class before linking this class @@ -1805,15 +1804,15 @@ bool InstanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* Klass* InstanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { const int n = local_interfaces()->length(); for (int i = 0; i < n; i++) { - Klass* intf1 = local_interfaces()->at(i); + InstanceKlass* intf1 = local_interfaces()->at(i); assert(intf1->is_interface(), "just checking type"); // search for field in current interface - if (InstanceKlass::cast(intf1)->find_local_field(name, sig, fd)) { + if (intf1->find_local_field(name, sig, fd)) { assert(fd->is_static(), "interface field must be static"); return intf1; } // search for field in direct superinterfaces - Klass* intf2 = InstanceKlass::cast(intf1)->find_interface_field(name, sig, fd); + Klass* intf2 = intf1->find_interface_field(name, sig, fd); if (intf2 != nullptr) return intf2; } // otherwise field lookup fails @@ -1832,8 +1831,8 @@ Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) if (intf != nullptr) return intf; } // 3) apply field lookup recursively if superclass exists - { Klass* supr = super(); - if (supr != nullptr) return InstanceKlass::cast(supr)->find_field(name, sig, fd); + { InstanceKlass* supr = java_super(); + if (supr != nullptr) return supr->find_field(name, sig, fd); } // 4) otherwise field lookup fails return nullptr; @@ -1852,8 +1851,8 @@ Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, bool is_static, fiel if (intf != nullptr) return intf; } // 3) apply field lookup recursively if superclass exists - { Klass* supr = super(); - if (supr != nullptr) return InstanceKlass::cast(supr)->find_field(name, sig, is_static, fd); + { InstanceKlass* supr = java_super(); + if (supr != nullptr) return supr->find_field(name, sig, is_static, fd); } // 4) otherwise field lookup fails return nullptr; @@ -1872,12 +1871,12 @@ bool InstanceKlass::find_local_field_from_offset(int offset, bool is_static, fie bool InstanceKlass::find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const { - Klass* klass = const_cast(this); + const InstanceKlass* klass = this; while (klass != nullptr) { - if (InstanceKlass::cast(klass)->find_local_field_from_offset(offset, is_static, fd)) { + if (klass->find_local_field_from_offset(offset, is_static, fd)) { return true; } - klass = klass->super(); + klass = klass->java_super(); } return false; } @@ -1920,7 +1919,7 @@ void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAP } void InstanceKlass::do_nonstatic_fields(FieldClosure* cl) { - InstanceKlass* super = superklass(); + InstanceKlass* super = java_super(); if (super != nullptr) { super->do_nonstatic_fields(cl); } @@ -1937,7 +1936,7 @@ static int compare_fields_by_offset(FieldInfo* a, FieldInfo* b) { } void InstanceKlass::print_nonstatic_fields(FieldClosure* cl) { - InstanceKlass* super = superklass(); + InstanceKlass* super = java_super(); if (super != nullptr) { super->print_nonstatic_fields(cl); } @@ -2232,17 +2231,17 @@ Method* InstanceKlass::uncached_lookup_method(const Symbol* name, OverpassLookupMode overpass_mode, PrivateLookupMode private_mode) const { OverpassLookupMode overpass_local_mode = overpass_mode; - const Klass* klass = this; + const InstanceKlass* klass = this; while (klass != nullptr) { - Method* const method = InstanceKlass::cast(klass)->find_method_impl(name, - signature, - overpass_local_mode, - StaticLookupMode::find, - private_mode); + Method* const method = klass->find_method_impl(name, + signature, + overpass_local_mode, + StaticLookupMode::find, + private_mode); if (method != nullptr) { return method; } - klass = klass->super(); + klass = klass->java_super(); overpass_local_mode = OverpassLookupMode::skip; // Always ignore overpass methods in superclasses } return nullptr; @@ -2252,12 +2251,12 @@ Method* InstanceKlass::uncached_lookup_method(const Symbol* name, // search through class hierarchy and return true if this class or // one of the superclasses was redefined bool InstanceKlass::has_redefined_this_or_super() const { - const Klass* klass = this; + const InstanceKlass* klass = this; while (klass != nullptr) { - if (InstanceKlass::cast(klass)->has_been_redefined()) { + if (klass->has_been_redefined()) { return true; } - klass = klass->super(); + klass = klass->java_super(); } return false; } @@ -3986,7 +3985,7 @@ void InstanceKlass::print_class_load_helper(ClassLoaderData* loader_data, // Class hierarchy info debug_stream.print(" klass: " PTR_FORMAT " super: " PTR_FORMAT, - p2i(this), p2i(superklass())); + p2i(this), p2i(java_super())); // Interfaces if (local_interfaces() != nullptr && local_interfaces()->length() > 0) { @@ -3994,7 +3993,7 @@ void InstanceKlass::print_class_load_helper(ClassLoaderData* loader_data, int length = local_interfaces()->length(); for (int i = 0; i < length; i++) { debug_stream.print(" " PTR_FORMAT, - p2i(InstanceKlass::cast(local_interfaces()->at(i)))); + p2i(local_interfaces()->at(i))); } } @@ -4207,19 +4206,17 @@ void InstanceKlass::oop_verify_on(oop obj, outputStream* st) { obj->oop_iterate(&blk); } - // JNIid class for jfieldIDs only // Note to reviewers: // These JNI functions are just moved over to column 1 and not changed // in the compressed oops workspace. -JNIid::JNIid(Klass* holder, int offset, JNIid* next) { +JNIid::JNIid(InstanceKlass* holder, int offset, JNIid* next) { _holder = holder; _offset = offset; _next = next; DEBUG_ONLY(_is_static_field_id = false;) } - JNIid* JNIid::find(int offset) { JNIid* current = this; while (current != nullptr) { @@ -4237,11 +4234,10 @@ void JNIid::deallocate(JNIid* current) { } } - -void JNIid::verify(Klass* holder) { +void JNIid::verify(InstanceKlass* holder) { int first_field_offset = InstanceMirrorKlass::offset_of_static_fields(); int end_field_offset; - end_field_offset = first_field_offset + (InstanceKlass::cast(holder)->static_field_size() * wordSize); + end_field_offset = first_field_offset + (holder->static_field_size() * wordSize); JNIid* current = this; while (current != nullptr) { @@ -4554,7 +4550,7 @@ void ClassHierarchyIterator::next() { } _visit_subclasses = true; // reset while (_current->next_sibling() == nullptr && _current != _root) { - _current = _current->superklass(); // backtrack; no more sibling subclasses left + _current = _current->java_super(); // backtrack; no more sibling subclasses left } if (_current == _root) { // Iteration is over (back at root after backtracking). Invalidate the iterator. diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index 3c0dd84b2d2fc..a158494736bec 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -988,7 +988,7 @@ class InstanceKlass: public Klass { static void deallocate_methods(ClassLoaderData* loader_data, Array* methods); void static deallocate_interfaces(ClassLoaderData* loader_data, - const Klass* super_klass, + const InstanceKlass* super_klass, Array* local_interfaces, Array* transitive_interfaces); void static deallocate_record_components(ClassLoaderData* loader_data, @@ -1205,7 +1205,7 @@ class PrintClassClosure : public KlassClosure { class JNIid: public CHeapObj { friend class VMStructs; private: - Klass* _holder; + InstanceKlass* _holder; JNIid* _next; int _offset; #ifdef ASSERT @@ -1214,11 +1214,11 @@ class JNIid: public CHeapObj { public: // Accessors - Klass* holder() const { return _holder; } + InstanceKlass* holder() const { return _holder; } int offset() const { return _offset; } JNIid* next() { return _next; } // Constructor - JNIid(Klass* holder, int offset, JNIid* next); + JNIid(InstanceKlass* holder, int offset, JNIid* next); // Identifier lookup JNIid* find(int offset); @@ -1232,7 +1232,7 @@ class JNIid: public CHeapObj { bool is_static_field_id() const { return _is_static_field_id; } void set_is_static_field_id() { _is_static_field_id = true; } #endif - void verify(Klass* holder); + void verify(InstanceKlass* holder); }; // An iterator that's used to access the inner classes indices in the diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp index 41ab8e325ab7c..17e2ccbc91109 100644 --- a/src/hotspot/share/oops/klass.cpp +++ b/src/hotspot/share/oops/klass.cpp @@ -611,12 +611,6 @@ GrowableArray* Klass::compute_secondary_supers(int num_extra_slots, } -// superklass links -InstanceKlass* Klass::superklass() const { - assert(super() == nullptr || super()->is_instance_klass(), "must be instance klass"); - return _super == nullptr ? nullptr : InstanceKlass::cast(_super); -} - // subklass links. Used by the compiler (and vtable initialization) // May be cleaned concurrently, so must use the Compile_lock. // The log parameter is for clean_weak_klass_links to report unlinked classes. @@ -679,11 +673,11 @@ void Klass::append_to_sibling_list() { assert_locked_or_safepoint(Compile_lock); } DEBUG_ONLY(verify();) - // add ourselves to superklass' subklass list - InstanceKlass* super = superklass(); + // add ourselves to super' subklass list + InstanceKlass* super = java_super(); if (super == nullptr) return; // special case: class Object assert((!super->is_interface() // interfaces cannot be supers - && (super->superklass() == nullptr || !is_interface())), + && (super->java_super() == nullptr || !is_interface())), "an interface can only be a subklass of Object"); // Make sure there is no stale subklass head @@ -692,7 +686,7 @@ void Klass::append_to_sibling_list() { for (;;) { Klass* prev_first_subklass = Atomic::load_acquire(&_super->_subklass); if (prev_first_subklass != nullptr) { - // set our sibling to be the superklass' previous first subklass + // set our sibling to be the super' previous first subklass assert(prev_first_subklass->is_loader_alive(), "May not attach not alive klasses"); set_next_sibling(prev_first_subklass); } diff --git a/src/hotspot/share/oops/klass.hpp b/src/hotspot/share/oops/klass.hpp index ac382fdba9844..1257f4cbcf882 100644 --- a/src/hotspot/share/oops/klass.hpp +++ b/src/hotspot/share/oops/klass.hpp @@ -297,7 +297,6 @@ class Klass : public Metadata { Klass* subklass(bool log = false) const; Klass* next_sibling(bool log = false) const; - InstanceKlass* superklass() const; void append_to_sibling_list(); // add newly created receiver to superklass' subklass list void set_next_link(Klass* k) { _next_link = k; } diff --git a/src/hotspot/share/oops/klassVtable.cpp b/src/hotspot/share/oops/klassVtable.cpp index e9da33b280e60..bb47496b40662 100644 --- a/src/hotspot/share/oops/klassVtable.cpp +++ b/src/hotspot/share/oops/klassVtable.cpp @@ -65,7 +65,7 @@ bool klassVtable::is_preinitialized_vtable() { // treated as any other public method in C for method over-ride purposes. void klassVtable::compute_vtable_size_and_num_mirandas( int* vtable_length_ret, int* num_new_mirandas, - GrowableArray* all_mirandas, const Klass* super, + GrowableArray* all_mirandas, const InstanceKlass* super, Array* methods, AccessFlags class_flags, u2 major_version, Handle classloader, Symbol* classname, Array* local_interfaces) { NoSafepointVerifier nsv; @@ -346,7 +346,7 @@ InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper break; } // if no override found yet, continue to search up - superk = superk->super() == nullptr ? nullptr : InstanceKlass::cast(superk->super()); + superk = superk->java_super(); } return superk; @@ -631,7 +631,7 @@ void klassVtable::initialize_vtable_and_check_constraints(TRAPS) { // However, the vtable entries are filled in at link time, and therefore // the superclass' vtable may not yet have been filled in. bool klassVtable::needs_new_vtable_entry(Method* target_method, - const Klass* super, + const InstanceKlass* super, Handle classloader, Symbol* classname, AccessFlags class_flags, @@ -683,7 +683,7 @@ bool klassVtable::needs_new_vtable_entry(Method* target_method, // a new entry Symbol* name = target_method->name(); Symbol* signature = target_method->signature(); - const Klass* k = super; + const InstanceKlass* k = super; Method* super_method = nullptr; InstanceKlass *holder = nullptr; Method* recheck_method = nullptr; @@ -722,7 +722,7 @@ bool klassVtable::needs_new_vtable_entry(Method* target_method, // Start with lookup result and continue to search up, for versions supporting transitive override if (major_version >= VTABLE_TRANSITIVE_OVERRIDE_VERSION) { - k = superk->super(); // haven't found an override match yet; continue to look + k = superk->java_super(); // haven't found an override match yet; continue to look } else { break; } @@ -741,9 +741,8 @@ bool klassVtable::needs_new_vtable_entry(Method* target_method, // miranda method in the super, whose entry it should re-use. // Actually, to handle cases that javac would not generate, we need // this check for all access permissions. - const InstanceKlass *sk = InstanceKlass::cast(super); - if (sk->has_miranda_methods()) { - if (sk->lookup_method_in_all_interfaces(name, signature, Klass::DefaultsLookupMode::find) != nullptr) { + if (super->has_miranda_methods()) { + if (super->lookup_method_in_all_interfaces(name, signature, Klass::DefaultsLookupMode::find) != nullptr) { return false; // found a matching miranda; we do not need a new entry } } @@ -775,7 +774,7 @@ bool klassVtable::is_miranda_entry_at(int i) { if (holder->is_interface()) { assert(m->is_public(), "should be public"); assert(ik()->implements_interface(holder) , "this class should implement the interface"); - if (is_miranda(m, ik()->methods(), ik()->default_methods(), ik()->super(), klass()->is_interface())) { + if (is_miranda(m, ik()->methods(), ik()->default_methods(), ik()->java_super(), klass()->is_interface())) { return true; } } @@ -837,7 +836,7 @@ bool klassVtable::is_miranda_entry_at(int i) { // Part of the Miranda Rights in the US mean that if you do not have // an attorney one will be appointed for you. bool klassVtable::is_miranda(Method* m, Array* class_methods, - Array* default_methods, const Klass* super, + Array* default_methods, const InstanceKlass* super, bool is_interface) { if (m->is_static() || m->is_private() || m->is_overpass()) { return false; @@ -866,12 +865,11 @@ bool klassVtable::is_miranda(Method* m, Array* class_methods, // Overpasses may or may not exist for supers for pass 1, // they should have been created for pass 2 and later. - for (const Klass* cursuper = super; cursuper != nullptr; cursuper = cursuper->super()) - { - Method* found_mth = InstanceKlass::cast(cursuper)->find_local_method(name, signature, - Klass::OverpassLookupMode::find, - Klass::StaticLookupMode::skip, - Klass::PrivateLookupMode::skip); + for (const InstanceKlass* cursuper = super; cursuper != nullptr; cursuper = cursuper->java_super()) { + Method* found_mth = cursuper->find_local_method(name, signature, + Klass::OverpassLookupMode::find, + Klass::StaticLookupMode::skip, + Klass::PrivateLookupMode::skip); // Ignore non-public methods in java.lang.Object if klass is an interface. if (found_mth != nullptr && (!is_interface || !SystemDictionary::is_nonpublic_Object_method(found_mth))) { @@ -893,7 +891,7 @@ bool klassVtable::is_miranda(Method* m, Array* class_methods, void klassVtable::add_new_mirandas_to_lists( GrowableArray* new_mirandas, GrowableArray* all_mirandas, Array* current_interface_methods, Array* class_methods, - Array* default_methods, const Klass* super, bool is_interface) { + Array* default_methods, const InstanceKlass* super, bool is_interface) { // iterate thru the current interface's method to see if it a miranda int num_methods = current_interface_methods->length(); @@ -913,9 +911,8 @@ void klassVtable::add_new_mirandas_to_lists( if (!is_duplicate) { // we don't want duplicate miranda entries in the vtable if (is_miranda(im, class_methods, default_methods, super, is_interface)) { // is it a miranda at all? - const InstanceKlass *sk = InstanceKlass::cast(super); // check if it is a duplicate of a super's miranda - if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::DefaultsLookupMode::find) == nullptr) { + if (super->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::DefaultsLookupMode::find) == nullptr) { new_mirandas->append(im); } if (all_mirandas != nullptr) { @@ -928,7 +925,7 @@ void klassVtable::add_new_mirandas_to_lists( void klassVtable::get_mirandas(GrowableArray* new_mirandas, GrowableArray* all_mirandas, - const Klass* super, + const InstanceKlass* super, Array* class_methods, Array* default_methods, Array* local_interfaces, @@ -962,7 +959,7 @@ void klassVtable::get_mirandas(GrowableArray* new_mirandas, int klassVtable::fill_in_mirandas(Thread* current, int initialized) { ResourceMark rm(current); GrowableArray mirandas(20); - get_mirandas(&mirandas, nullptr, ik()->super(), ik()->methods(), + get_mirandas(&mirandas, nullptr, ik()->java_super(), ik()->methods(), ik()->default_methods(), ik()->local_interfaces(), klass()->is_interface()); for (int i = 0; i < mirandas.length(); i++) { diff --git a/src/hotspot/share/oops/klassVtable.hpp b/src/hotspot/share/oops/klassVtable.hpp index 3bd07a9143efc..b8635e7f14b97 100644 --- a/src/hotspot/share/oops/klassVtable.hpp +++ b/src/hotspot/share/oops/klassVtable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,7 @@ class klassVtable { static void compute_vtable_size_and_num_mirandas(int* vtable_length, int* num_new_mirandas, GrowableArray* all_mirandas, - const Klass* super, + const InstanceKlass* super, Array* methods, AccessFlags class_flags, u2 major_version, @@ -116,7 +116,7 @@ class klassVtable { int initialize_from_super(Klass* super); void put_method_at(Method* m, int index); static bool needs_new_vtable_entry(Method* m, - const Klass* super, + const InstanceKlass* super, Handle classloader, Symbol* classname, AccessFlags access_flags, @@ -135,7 +135,7 @@ class klassVtable { bool is_miranda_entry_at(int i); int fill_in_mirandas(Thread* current, int initialized); static bool is_miranda(Method* m, Array* class_methods, - Array* default_methods, const Klass* super, + Array* default_methods, const InstanceKlass* super, bool is_interface); static void add_new_mirandas_to_lists( GrowableArray* new_mirandas, @@ -143,12 +143,12 @@ class klassVtable { Array* current_interface_methods, Array* class_methods, Array* default_methods, - const Klass* super, + const InstanceKlass* super, bool is_interface); static void get_mirandas( GrowableArray* new_mirandas, GrowableArray* all_mirandas, - const Klass* super, + const InstanceKlass* super, Array* class_methods, Array* default_methods, Array* local_interfaces, diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 098bd729c0bf7..659dccc224c67 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -1177,7 +1177,7 @@ JVM_ENTRY(jobjectArray, JVM_GetClassInterfaces(JNIEnv *env, jclass cls)) if (klass->is_instance_klass()) { // Regular instance klass, fill in all local interfaces for (int index = 0; index < size; index++) { - Klass* k = InstanceKlass::cast(klass)->local_interfaces()->at(index); + InstanceKlass* k = InstanceKlass::cast(klass)->local_interfaces()->at(index); result->obj_at_put(index, k->java_mirror()); } } else { diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index dd8ee7c93fa92..efc7bfde3dd19 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -1476,7 +1476,7 @@ class ReassignedField { // Gets the fields of `klass` that are eliminated by escape analysis and need to be reassigned static GrowableArray* get_reassigned_fields(InstanceKlass* klass, GrowableArray* fields, bool is_jvmci) { - InstanceKlass* super = klass->superklass(); + InstanceKlass* super = klass->java_super(); if (super != nullptr) { get_reassigned_fields(super, fields, is_jvmci); } diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 6fc16f9b04520..b95c1aaf60cc5 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -321,7 +321,7 @@ /* JNI IDs */ \ /***********/ \ \ - nonstatic_field(JNIid, _holder, Klass*) \ + nonstatic_field(JNIid, _holder, InstanceKlass*) \ nonstatic_field(JNIid, _next, JNIid*) \ nonstatic_field(JNIid, _offset, int) \ \