Skip to content

Commit

Permalink
introduce print_on_maybe_null
Browse files Browse the repository at this point in the history
  • Loading branch information
MBaesken committed Jun 26, 2024
1 parent 530375f commit fb63c5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 41 deletions.
51 changes: 10 additions & 41 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,41 +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();
}
if (class_annotations() != nullptr) {
st->print(BULLET"class annotations: ");
class_annotations()->print_value_on(st);
st->cr();
}
if (class_type_annotations() != nullptr) {
st->print(BULLET"class type annotations: ");
class_type_annotations()->print_value_on(st);
st->cr();
}
if (fields_annotations() != nullptr) {
st->print(BULLET"field annotations: ");
fields_annotations()->print_value_on(st);
st->cr();
}
if (fields_type_annotations() != nullptr) {
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 @@ -3638,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

0 comments on commit fb63c5a

Please sign in to comment.