Skip to content

8352437: Support --add-exports with -XX:+AOTClassLinking #24124

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

iklam
Copy link
Member

@iklam iklam commented Mar 20, 2025

-XX:+AOTClassLinking requires the CDS archived full module graph (FMG).

  • Before this PR, when --add-export is specified, FMG is disabled, so AOT caches created with -XX:+AOTClassLinking cannot be loaded.
  • After this PR, if the exact same --add-export flags as specified across the training/assembly/production phases, the FMG can be used, so we can use so AOT caches created with -XX:+AOTClassLinking.

The change itself is straight-forward: just remember the --add-export flags specified during AOT cache creation, and check the exact same ones are used during the production run.

I did a fair amount of refactoring to change the "exact options specified" checks in modules.cpp, so more such options can be easily added in the future (we need to handle --add-reads and --add-opens in future RFEs).

(Note: this PR depends on #24122 )


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-8352437: Support --add-exports with -XX:+AOTClassLinking (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24124

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 20, 2025

👋 Welcome back iklam! A progress list of the required criteria for merging this PR into pr/24122 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 Mar 20, 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:

8352437: Support --add-exports with -XX:+AOTClassLinking

Reviewed-by: matsaave

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 60 new commits pushed to the master branch:

  • 6891490: 8353324: Clean up of comments and import after 8319192
  • 07fd666: 8342984: Bump minimum boot jdk to JDK 24
  • 6a46d55: 8353129: CDS ArchiveRelocation tests fail after JDK-8325132
  • 19eabaf: 8353227: JFR: Prepare tests for strong parser validation
  • 564066d: 8353118: Deprecate the use of java.locale.useOldISOCodes system property
  • a1ab1d8: 8353449: [BACKOUT] One instance of STATIC_LIB_CFLAGS was missed in JDK-8345683
  • 2a31f69: 8353331: Test ForkJoinPool20Test::testFixedDelaySequence is failing
  • 1809138: 8352284: EXTRA_CFLAGS incorrectly applied to BUILD_LIBJVM src/hotspot C++ source files
  • cef5610: 8353272: One instance of STATIC_LIB_CFLAGS was missed in JDK-8345683
  • 6801eb8: 8352709: Remove bad timing annotations from WhileOpTest.java
  • ... and 50 more: https://git.openjdk.org/jdk/compare/58ef4015b7313292a7c7634d3e00e3a904bbdc50...master

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 Mar 20, 2025

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

  • core-libs
  • hotspot

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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 20, 2025
@mlbridge
Copy link

mlbridge bot commented Mar 20, 2025

Webrevs

@iklam iklam changed the title 8352437: -XX:+AOTClassLinking is not compatible with --add-export 8352437: Support --add-exports with -XX:+AOTClassLinking Mar 24, 2025
@AlanBateman
Copy link
Contributor

Is the motivation tests or code that is making use of JDK internals? No objection to the change of course, I'm curious why we are doing this.

@iklam
Copy link
Member Author

iklam commented Mar 24, 2025

Is the motivation tests or code that is making use of JDK internals? No objection to the change of course, I'm curious why we are doing this.

The motivation is for both testing (e.g., expose the jdk.internal.test.cds.WhiteBox package proposed by JDK-8352528), as well as supporting existing applications that use --add-exports to access JDK internals.

While the use of --add-exports by applications is discouraged, I think the AOT cache should provide the same level of support as when the AOT cache is not used, since the effort for extending this support is quite small.

Copy link
Member

@calvinccheung calvinccheung left a comment

Choose a reason for hiding this comment

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

Code changes look clean. I just have two minor comments on the tests.

@@ -33,7 +33,6 @@
import jdk.test.lib.util.FileUtils;
import jdk.test.lib.cds.CDSJarUtils.JarOptions;


Copy link
Member

Choose a reason for hiding this comment

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

This file has no change other than the above blank line deletion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 90 to 91
// (4) Dump = specified twice, Run = specified twice (but in different order)
// Should still be able to use FMG (values are sorted by CDS).
Copy link
Member

Choose a reason for hiding this comment

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

How about add another test case where the values are specified in the same order?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/24122 to master March 27, 2025 20:33
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout 8352437-aot-class-linking-incompatible-with-add-exports
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk
Copy link

openjdk bot commented Mar 27, 2025

@iklam this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout 8352437-aot-class-linking-incompatible-with-add-exports
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added merge-conflict Pull request has merge conflict with target branch and removed rfr Pull request is ready for review labels Mar 27, 2025
@openjdk openjdk bot added rfr Pull request is ready for review and removed merge-conflict Pull request has merge conflict with target branch labels Mar 27, 2025
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.

Changes and cleanup look good! Thanks!

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

iklam commented Apr 2, 2025

Thanks @calvinccheung and @matias9927 for the review
Passed tiers1-4 and build-tiers5.
/integrate

@openjdk
Copy link

openjdk bot commented Apr 2, 2025

Going to push as commit 096e70d.
Since your change was applied there have been 62 commits pushed to the master branch:

  • 6970cf6: 8352775: JVM crashes with -XX:AOTMode=create -XX:+UseZGC
  • afcad8c: 5043343: FileImageInputStream and FileImageOutputStream do not properly track streamPos for RandomAccessFile
  • 6891490: 8353324: Clean up of comments and import after 8319192
  • 07fd666: 8342984: Bump minimum boot jdk to JDK 24
  • 6a46d55: 8353129: CDS ArchiveRelocation tests fail after JDK-8325132
  • 19eabaf: 8353227: JFR: Prepare tests for strong parser validation
  • 564066d: 8353118: Deprecate the use of java.locale.useOldISOCodes system property
  • a1ab1d8: 8353449: [BACKOUT] One instance of STATIC_LIB_CFLAGS was missed in JDK-8345683
  • 2a31f69: 8353331: Test ForkJoinPool20Test::testFixedDelaySequence is failing
  • 1809138: 8352284: EXTRA_CFLAGS incorrectly applied to BUILD_LIBJVM src/hotspot C++ source files
  • ... and 52 more: https://git.openjdk.org/jdk/compare/58ef4015b7313292a7c7634d3e00e3a904bbdc50...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Apr 2, 2025

@iklam Pushed as commit 096e70d.

💡 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
Development

Successfully merging this pull request may close these issues.

4 participants