-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8366498: Simplify ClassFileParser::parse_super_class #27026
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
8366498: Simplify ClassFileParser::parse_super_class #27026
Conversation
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
@iklam This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 7 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
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 does correct the cast but as you suggest this code should actually be unreachable - is_klass()
will fail as no classes have been resolved at this stage of classfile parsing,
I removed the code for checking |
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.
Amazing how one incorrect cast led to that cascade of code changes. :)
Overall seems valid. A couple of nits.
Thanks
} else { | ||
assert(_class_name == vmSymbols::java_lang_Object(), "already checked"); | ||
_super_klass = nullptr; |
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 seems unnecessary. We have already check the name and _super_klass
is initialized to null.
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 think it help people who wonder why _super_klass
is not updated in this case. Maybe I can change the assignment to
asssert(_super_klass == nullptr, "already initialized");
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 would just have:
else {
// The class is Object - so no superclass
}
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.
My asserts say the same thing, except they comes with proofs that they are not lying.
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 don't like the 'else' either.
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've removed the trailing else and shuffled the asserts around as @coleenp suggested.
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.
It's a minor point really but while you're making this logic less confusing, might as well fix the extra else.
@@ -5777,8 +5768,8 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st | |||
"java.lang.Object cannot implement an interface in class file %s", | |||
CHECK); | |||
} |
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 somewhat strange logic. Seems like there should be an assert that _super_klass == nullptr then an 'else' at 5779 and an assert that _super_class_index != 0. The trailing else is confusing and it checks something here at 5775.
} else { | ||
assert(_class_name == vmSymbols::java_lang_Object(), "already checked"); | ||
_super_klass = nullptr; |
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 don't like the 'else' either.
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 makes a lot more sense.
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.
Looks good. Thanks
Thanks @dholmes-ora @coleenp for the review |
Going to push as commit 79a1a98.
Your commit was automatically rebased without conflicts. |
The if
cp->resolved_klass_at()
is never true called because we are very early in class file parsing, so no klass CP entries have been resolved at this point.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27026/head:pull/27026
$ git checkout pull/27026
Update a local copy of the PR:
$ git checkout pull/27026
$ git pull https://git.openjdk.org/jdk.git pull/27026/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27026
View PR using the GUI difftool:
$ git pr show -t 27026
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27026.diff
Using Webrev
Link to Webrev Comment