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

8320002: Remove obsolete CDS check in Reflection::verify_class_access() #17232

Conversation

calvinccheung
Copy link
Member

@calvinccheung calvinccheung commented Jan 3, 2024

This fix removes an obsolete CDS check. Please review.

Passed tiers 1 - 4 testing.


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-8320002: Remove obsolete CDS check in Reflection::verify_class_access() (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17232/head:pull/17232
$ git checkout pull/17232

Update a local copy of the PR:
$ git checkout pull/17232
$ git pull https://git.openjdk.org/jdk.git pull/17232/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17232

View PR using the GUI difftool:
$ git pr show -t 17232

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17232.diff

Webrev

Link to Webrev Comment

@calvinccheung
Copy link
Member Author

/label add hotspot-runtime

@calvinccheung calvinccheung marked this pull request as ready for review January 3, 2024 00:40
@bridgekeeper
Copy link

bridgekeeper bot commented Jan 3, 2024

👋 Welcome back ccheung! 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 openjdk bot added rfr Pull request is ready for review hotspot-runtime hotspot-runtime-dev@openjdk.org labels Jan 3, 2024
@openjdk
Copy link

openjdk bot commented Jan 3, 2024

@calvinccheung
The hotspot-runtime label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Jan 3, 2024

Webrevs

@dholmes-ora
Copy link
Member

This would seem to introduce a change in behaviour. During dumping we may now get an access exception when previously access was assumed to be okay.

@calvinccheung
Copy link
Member Author

This would seem to introduce a change in behaviour. During dumping we may now get an access exception when previously access was assumed to be okay.

During static dump, if an exception is encountered, it would just log a CDS warning message and continue processing the next entry in the classlist. For example, the code in classListParser.cpp.

@dholmes-ora
Copy link
Member

During static dump, if an exception is encountered, it would just log a CDS warning message and continue processing the next entry in the classlist.

Exactly! It would skip the class that triggered the exception, which is a behaviour change to what happens now.

@iklam
Copy link
Member

iklam commented Jan 24, 2024

The code that Calvin is removing is very old code. I guess at one time during the initial development of modules in JDK 9, even when the access was perfectly OK, the "real" check would fail because some information were not properly set up. So as a hack, someone added:

if (DumpSharedSpaces) {
  return ACCESS_OK
}
if (some_real_check()) { // <-- would cause failures/assert/etc if DumpSharedSpaces==true
}

Unfortunately there's no history for why this hack was added:

https://github.com/openjdk/jdk/blame/6e86904a94d2ed2815aa6e3364c048dac595320d/src/hotspot/share/runtime/reflection.cpp#L458-L466

However, that problem doesn't exist anymore, so we can remove this hack.

Yes, this changes behavior. However, we run a very limited set of Java code during "java -Xshare:dump". Specifically, we never execute any user-supplied code. So even if we perform the real checks, we should always get ACCESS_OK anyway. If we don't, that will be a bug, and we better know about it.

Copy link
Member

@iklam iklam left a comment

Choose a reason for hiding this comment

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

LGTM.

@openjdk
Copy link

openjdk bot commented Jan 24, 2024

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

8320002: Remove obsolete CDS check in Reflection::verify_class_access()

Reviewed-by: iklam, matsaave, dholmes

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 589 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 openjdk bot added the ready Pull request is ready to be integrated label Jan 24, 2024
Copy link
Contributor

@matias9927 matias9927 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 @iklam for the explanation.

@dholmes-ora
Copy link
Member

Yes, this changes behavior. However, we run a very limited set of Java code during "java -Xshare:dump". Specifically, we never execute any user-supplied code. So even if we perform the real checks, we should always get ACCESS_OK anyway. If we don't, that will be a bug, and we better know about it.

Seems to me like this is/was simply a quick exit path: we know/expect all checks to pass so why bother actually performing them. I'm fine with now actually performing them, in case at some point something is added that could fail, as long as we don't expect anything to actually start failing now.

Thanks.

@calvinccheung
Copy link
Member Author

Thanks @dholmes-ora, @iklam, @matias9927 for the review.

/integrate

@openjdk
Copy link

openjdk bot commented Feb 20, 2024

Going to push as commit 221fbfb.
Since your change was applied there have been 690 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 Feb 20, 2024
@openjdk openjdk bot closed this Feb 20, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 20, 2024
@openjdk
Copy link

openjdk bot commented Feb 20, 2024

@calvinccheung Pushed as commit 221fbfb.

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

@calvinccheung calvinccheung deleted the 8320002-remove-obsolete-CDS-check branch February 20, 2024 22:11
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.

4 participants