-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8323832: Load JVMCI with the platform class loader #17520
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
Conversation
|
👋 Welcome back dnsimon! A progress list of the required criteria for merging this PR into |
|
@dougxc The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
44c0742 to
36ea450
Compare
| permission java.security.AllPermission; | ||
| }; | ||
|
|
||
| grant codeBase "jrt:/jdk.internal.vm.ci" { |
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 required as JVMCI is no longer loaded by the boot loader but should retain all permissions.
Webrevs
|
|
Hello. I'm not a reviewer but I read through the conversation in JIRA and saw this comment:
There is zero reason to do this. |
Thanks! I've simplified the test accordingly: 1642276 |
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.
The actual changes to load JVMCI via the platform loader seem fine.
I'm still puzzled by the need to do this as any non-delegating classloader would have allowed this even if JVMCI were loaded by the bootloader. And I don't understand how your test is working as it is using a delegating classloader.
| ClassLoader pcl = ClassLoader.getPlatformClassLoader(); | ||
| URLClassLoader ucl = new URLClassLoader(cp, 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 am missing something here, a URLClassLoader first delegates to its parent before searching its URLs, so how does this not find the platform loader versions of the JVMCI classes?
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.
With new URLClassLoader(cp, null), the URL loader delegates directly to the boot loader, by-passing the platform loader.
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.
<face-palm>
Thanks Doug.
As far as I understand, even a non-delegating classloader cannot redefine a class loaded by the boot loader. I modified the test to show this and get: Test modification: |
Right, using Would be nice if the JavaDoc for |
| if (new File(e).isDirectory()) { | ||
| e = e + File.separator; | ||
| } | ||
| cp[i] = new URI("file:" + e).toURL(); |
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 should be cp[i] = file.toURI().toURL() as a file path needs encoding to be URI path component.
Interesting. I'm not sure why that should be happening in this case. I can imagine a potential split-package issue with the bootloader that doesn't happen with the platform loader. I will look into it. |
|
@dougxc 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 24 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 |
It can. You need to check if class is already loaded by trying |
You're right. I had forgotten the intricacies of class loader delegation. The only hard constraint on loading a class in multiple loaders is that |
Just to add that this restriction was relaxed in Java 9 to allow java.* classes be defined by the platform class loader. The code that is linked to here throws if the class loader is not the platform class loader. There isn't a user accessible ClassLoader object for the boot loader and testing |
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.
Build changes are trivially fine
|
I'm closing this PR as the Native Image use case https://bugs.openjdk.org/browse/JDK-8323832 was opened for can be solved with an appropriately crafted custom loader that does not delegate loading of JVMCI classes. Thanks for the reviews anyway, especially @xxDark for highlighting that this change is unnecessary. |
Thanks @xxDark . I knew it should work. :) |
This PR changes
jdk.internal.vm.cisuch that it is loaded by the platform class loader instead of the boot class loader. This allows Native Image to load a version of JVMCI different than the version on top of which Native Image is running. This capability is demonstrated and tested byLoadAlternativeJVMCI.java.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17520/head:pull/17520$ git checkout pull/17520Update a local copy of the PR:
$ git checkout pull/17520$ git pull https://git.openjdk.org/jdk.git pull/17520/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17520View PR using the GUI difftool:
$ git pr show -t 17520Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17520.diff
Webrev
Link to Webrev Comment