Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/hotspot/share/classfile/classFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4092,31 +4092,29 @@ static Array<InstanceKlass*>* 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.
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/fieldLayoutBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/systemDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ bool SystemDictionary::check_shared_class_super_types(InstanceKlass* ik, Handle
// load <ik> 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) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/vmClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<InstanceKlass*>* ifs = klass->local_interfaces();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
70 changes: 33 additions & 37 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<InstanceKlass*>* local_interfaces,
Array<InstanceKlass*>* transitive_interfaces) {
// Only deallocate transitive interfaces if not empty, same as super class
Expand All @@ -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<InstanceKlass*>* 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<InstanceKlass*>(loader_data, ti);
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<InstanceKlass*>(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;
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -3986,15 +3985,15 @@ 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) {
debug_stream.print(" interfaces:");
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)));
}
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/oops/instanceKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ class InstanceKlass: public Klass {
static void deallocate_methods(ClassLoaderData* loader_data,
Array<Method*>* methods);
void static deallocate_interfaces(ClassLoaderData* loader_data,
const Klass* super_klass,
const InstanceKlass* super_klass,
Array<InstanceKlass*>* local_interfaces,
Array<InstanceKlass*>* transitive_interfaces);
void static deallocate_record_components(ClassLoaderData* loader_data,
Expand Down Expand Up @@ -1205,7 +1205,7 @@ class PrintClassClosure : public KlassClosure {
class JNIid: public CHeapObj<mtClass> {
friend class VMStructs;
private:
Klass* _holder;
InstanceKlass* _holder;
JNIid* _next;
int _offset;
#ifdef ASSERT
Expand All @@ -1214,11 +1214,11 @@ class JNIid: public CHeapObj<mtClass> {

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);

Expand All @@ -1232,7 +1232,7 @@ class JNIid: public CHeapObj<mtClass> {
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
Expand Down
Loading