Skip to content

Conversation

iklam
Copy link
Member

@iklam iklam commented Sep 1, 2025

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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8366498: Simplify ClassFileParser::parse_super_class (Enhancement - P4)

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

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 1, 2025

👋 Welcome back iklam! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 1, 2025

@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:

8366498: Simplify ClassFileParser::parse_super_class

Reviewed-by: dholmes, coleenp

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 master branch:

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 master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Sep 1, 2025

@iklam The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added hotspot-runtime hotspot-runtime-dev@openjdk.org rfr Pull request is ready for review labels Sep 1, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 1, 2025

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a 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,

@iklam
Copy link
Member Author

iklam commented Sep 1, 2025

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 is_klass(). I added an assert() and it doesn't get hit at all in local testing. For curiosity, I will run it through the JCK and to see if we ever come here with a resolved class. I will remove the assert in the final version.

@iklam iklam changed the title 8366498: Wrong InstanceKlass::cast() in ClassFileParser::parse_super_class 8366498: Simplify ClassFileParser::parse_super_class Sep 1, 2025
Copy link
Member

@dholmes-ora dholmes-ora left a 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

Comment on lines 5796 to 5798
} else {
assert(_class_name == vmSymbols::java_lang_Object(), "already checked");
_super_klass = nullptr;
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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
}

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 1, 2025
Copy link
Contributor

@coleenp coleenp left a 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);
}
Copy link
Contributor

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.

Comment on lines 5796 to 5798
} else {
assert(_class_name == vmSymbols::java_lang_Object(), "already checked");
_super_klass = nullptr;
Copy link
Contributor

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.

Copy link
Contributor

@coleenp coleenp left a 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.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Sep 4, 2025
Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 4, 2025
@iklam
Copy link
Member Author

iklam commented Sep 4, 2025

Thanks @dholmes-ora @coleenp for the review
/integrate

@openjdk
Copy link

openjdk bot commented Sep 4, 2025

Going to push as commit 79a1a98.
Since your change was applied there have been 12 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 4, 2025
@openjdk openjdk bot closed this Sep 4, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 4, 2025
@openjdk
Copy link

openjdk bot commented Sep 4, 2025

@iklam Pushed as commit 79a1a98.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants