-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8352003: Support --add-opens with -XX:+AOTClassLinking #24695
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 ccheung! A progress list of the required criteria for merging this PR into |
@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:
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 245 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 |
@calvinccheung 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. |
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.
LGTM!
Do we have a test case where If we don't have a test yet, I think we can modify the existing test to iterate this block twice: once with jdk/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/AddOpens.java Lines 85 to 105 in ad7c475
|
Yes, the new test |
AddopensOption.java only checks if the --add-opens is accepted. It doesn't check if the option has any effect. I think it's better to run |
I've modified the AppOpens.java test to include |
@@ -162,6 +162,7 @@ public static ModuleLayer boot() { | |||
bootLayer = archivedBootLayer.bootLayer(); | |||
BootLoader.getUnnamedModule(); // trigger <clinit> of BootLoader. | |||
CDS.defineArchivedModules(ClassLoaders.platformClassLoader(), ClassLoaders.appClassLoader()); | |||
boolean extraExportsOrOpens = addExtraExportsAndOpens(bootLayer); |
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.
(1) The returned value of addExtraExportsAndOpens()
is not used. So I think this function can be changed to void
, and all occurrences of the local variable extraExportsOrOpens
can be removed.
(2) I traced the code paths that depend on the effects of --add-opens
and --add-exports
. It Looks like some of the effects are recorded in the java.lang.Module$ReflectionData::export
table:
/**
* A module (1st key) exports or opens a package to another module
* (2nd key). The map value is a map of package name to a boolean
* that indicates if the package is opened.
*/
static final WeakPairMap<Module, Module, Map<String, Boolean>> exports =
new WeakPairMap<>();
This table is not stored as part of the ArchivedBootLayer
, so we must re-initialize this table in the production run. @AlanBateman could you confirm that this is correct.
Eventually, we should enhance the ArchivedBootLayer
to also include the tables in Module$ReflectionData
. That will obviate the call to addExtraExportsAndOpens()
and save a few bytecodes during start-up (but the overall impact would be small, so it's not critical in the current PR). Because these tables use WeakReference, we need to wait for JDK-8354897.
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.
Fixed (1) above.
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.
(2) I traced the code paths that depend on the effects of
--add-opens
and--add-exports
. It Looks like some of the effects are recorded in thejava.lang.Module$ReflectionData::export
table:/** * A module (1st key) exports or opens a package to another module * (2nd key). The map value is a map of package name to a boolean * that indicates if the package is opened. */ static final WeakPairMap<Module, Module, Map<String, Boolean>> exports = new WeakPairMap<>();
This table is not stored as part of the
ArchivedBootLayer
, so we must re-initialize this table in the production run. @AlanBateman could you confirm that this is correct.
In the changes for "JEP draft: Prepare final means final", this is changed significantly so that reflectively exporting or opening a package during startup will add to openPackages/exportedPackages. Once the VM is fully initialized then reflective change via the addExports/addOpens API make use of ReflectionData. So no ReflectionData or weak refs setup for --add-exports/--add-opens. We could potential separate this out in advance so that ReflectionData doesn't need to be re-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.
LGTM
/contributor add @AlanBateman |
@calvinccheung |
Thanks @iklam @AlanBateman @matias9927 for the review. /integrate |
Going to push as commit 597bcc6.
Your commit was automatically rebased without conflicts. |
@calvinccheung Pushed as commit 597bcc6. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This RFE allows --add-opens to be specified for AOT cache creation. AOT cache can be used during production run with --add-opens option as long as the same set of options is used during assembly phase.
Passed tiers 1 - 4 testing.
Progress
Issue
Reviewers
Contributors
<[email protected]>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24695/head:pull/24695
$ git checkout pull/24695
Update a local copy of the PR:
$ git checkout pull/24695
$ git pull https://git.openjdk.org/jdk.git pull/24695/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24695
View PR using the GUI difftool:
$ git pr show -t 24695
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24695.diff
Using Webrev
Link to Webrev Comment