Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8333363: ubsan: instanceKlass.cpp: runtime error: member call on null pointer of type 'struct AnnotationArray' #19885

Closed
wants to merge 3 commits into from
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
35 changes: 10 additions & 25 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3560,9 +3560,7 @@ void InstanceKlass::print_on(outputStream* st) const {
}
}
}
if (default_vtable_indices() != nullptr) {
st->print(BULLET"default vtable indices: "); default_vtable_indices()->print_value_on(st); st->cr();
}
print_on_maybe_null(st, BULLET"default vtable indices: ", default_vtable_indices());
st->print(BULLET"local interfaces: "); local_interfaces()->print_value_on(st); st->cr();
st->print(BULLET"trans. interfaces: "); transitive_interfaces()->print_value_on(st); st->cr();

Expand All @@ -3589,25 +3587,18 @@ void InstanceKlass::print_on(outputStream* st) const {
}
}
st->print(BULLET"constants: "); constants()->print_value_on(st); st->cr();
if (class_loader_data() != nullptr) {
st->print(BULLET"class loader data: ");
class_loader_data()->print_value_on(st);
st->cr();
}
if (source_file_name() != nullptr) {
st->print(BULLET"source file: ");
source_file_name()->print_value_on(st);
st->cr();
}

print_on_maybe_null(st, BULLET"class loader data: ", class_loader_data());
print_on_maybe_null(st, BULLET"source file: ", source_file_name());
if (source_debug_extension() != nullptr) {
st->print(BULLET"source debug extension: ");
st->print("%s", source_debug_extension());
st->cr();
}
st->print(BULLET"class annotations: "); class_annotations()->print_value_on(st); st->cr();
st->print(BULLET"class type annotations: "); class_type_annotations()->print_value_on(st); st->cr();
st->print(BULLET"field annotations: "); fields_annotations()->print_value_on(st); st->cr();
st->print(BULLET"field type annotations: "); fields_type_annotations()->print_value_on(st); st->cr();
print_on_maybe_null(st, BULLET"class annotations: ", class_annotations());
print_on_maybe_null(st, BULLET"class type annotations: ", class_type_annotations());
print_on_maybe_null(st, BULLET"field annotations: ", fields_annotations());
print_on_maybe_null(st, BULLET"field type annotations: ", fields_type_annotations());
{
bool have_pv = false;
// previous versions are linked together through the InstanceKlass
Expand All @@ -3622,16 +3613,10 @@ void InstanceKlass::print_on(outputStream* st) const {
if (have_pv) st->cr();
}

if (generic_signature() != nullptr) {
st->print(BULLET"generic signature: ");
generic_signature()->print_value_on(st);
st->cr();
}
print_on_maybe_null(st, BULLET"generic signature: ", generic_signature());
st->print(BULLET"inner classes: "); inner_classes()->print_value_on(st); st->cr();
st->print(BULLET"nest members: "); nest_members()->print_value_on(st); st->cr();
if (record_components() != nullptr) {
st->print(BULLET"record components: "); record_components()->print_value_on(st); st->cr();
}
print_on_maybe_null(st, BULLET"record components: ", record_components());
st->print(BULLET"permitted subclasses: "); permitted_subclasses()->print_value_on(st); st->cr();
if (java_mirror() != nullptr) {
st->print(BULLET"java mirror: ");
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/oops/metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,13 @@ class Metadata : public MetaspaceObj {
static void mark_on_stack(Metadata* m) { m->set_on_stack(true); }
};

template <typename M>
static void print_on_maybe_null(outputStream* st, const char* str, const M* m) {
if (nullptr != m) {
st->print_raw(str);
m->print_value_on(st);
st->cr();
}
}

#endif // SHARE_OOPS_METADATA_HPP