-
Notifications
You must be signed in to change notification settings - Fork 6.3k
8380129: Remove AccessFlags::print_on in favor of context-specific printing #30746
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3702,18 +3702,19 @@ const char* InstanceKlass::init_state_name() const { | |
| return state_names[init_state()]; | ||
| } | ||
|
|
||
| #if !defined(PRODUCT) || INCLUDE_JVMTI | ||
| void InstanceKlass::print_class_flags(outputStream* st) const { | ||
| AccessFlags flags = access_flags(); | ||
| AccessFlags flags(compute_modifier_flags()); | ||
| if (flags.is_private ()) st->print("private "); | ||
| if (flags.is_protected ()) st->print("protected "); | ||
| if (flags.is_public ()) st->print("public "); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: use the same order as for fields and methods. |
||
| if (flags.is_static ()) st->print("static "); | ||
| if (flags.is_final ()) st->print("final "); | ||
| if (flags.is_interface ()) st->print("interface "); | ||
| if (flags.is_abstract ()) st->print("abstract "); | ||
| if (flags.is_annotation()) st->print("annotation "); | ||
| if (flags.is_enum ()) st->print("enum "); | ||
| if (flags.is_synthetic ()) st->print("synthetic "); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The bit for SYNTHETIC, 0x1000, comes before ANNOTATION, 0x2000, and ENUM, 0x4000. That should be tracked in a separate issue though. |
||
| } | ||
| #endif // !defined(PRODUCT) || INCLUDE_JVMTI | ||
|
|
||
| void InstanceKlass::print_on(outputStream* st) const { | ||
| assert(is_klass(), "must be klass"); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,6 @@ void fieldDescriptor::reinitialize(InstanceKlass* ik, const FieldInfo& fieldinfo | |
| guarantee(_fieldinfo.name_index() != 0 && _fieldinfo.signature_index() != 0, "bad constant pool index for fieldDescriptor"); | ||
| } | ||
|
|
||
| #if !defined(PRODUCT) || INCLUDE_JVMTI | ||
| void fieldDescriptor::print_access_flags(outputStream* st) const { | ||
| AccessFlags flags = access_flags(); | ||
| if (flags.is_public ()) st->print("public "); | ||
|
|
@@ -121,7 +120,6 @@ void fieldDescriptor::print_access_flags(outputStream* st) const { | |
| if (flags.is_enum ()) st->print("enum "); | ||
| if (flags.is_synthetic()) st->print("synthetic "); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same SYNTHETIC remark here. |
||
| } | ||
| #endif // !defined(PRODUCT) || INCLUDE_JVMTI | ||
|
|
||
| void fieldDescriptor::print_on(outputStream* st) const { | ||
| print_access_flags(st); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incomplete. If the class is an inner class then additional access flags are possible (private, protected, static).
EDIT: Hmm jvm_constants.h does not recognise this either via
JVM_RECOGNIZED_CLASS_MODIFIERS. Not sure how this should be handled.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also do we need to handle ACC_MODULE, or do we not actually create an
instanceKlassfor those?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On jdk side we never have Class for modules. These classfiles are exclusively handled by Java code in ModuleDescriptor I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have now changed it to use
compute_modifier_flags()instead ofaccess_flags()directly. With this, we get member-class modifiers printed. I expanded the test which shows thatprivate/protected staticgets printed. This matches the class' modifiers, which feels like the correct behavior.ACC_MODULEis not needed here because it never becomes anInstanceKlass. It is rejected as a normal class during parsing.