Skip to content

Conversation

@iklam
Copy link
Member

@iklam iklam commented Dec 10, 2025

In legacy CDS, Java objects used by certain classes are computed ahead of time using "object subgraphs"

static ArchivableStaticFieldInfo archive_subgraph_entry_fields[] = {
{"java/lang/Integer$IntegerCache", "archivedCache"},
{"java/lang/Long$LongCache", "archivedCache"},
{"java/lang/Byte$ByteCache", "archivedCache"},

Examples of subgraphs:

  • java.lang.Integer$IntegerCache::cache
  • jdk.internal.module.ArchivedBootLayer::bootLayer

The implementation requires special code (in both Java and C++) to be executed when a CDS archive is created or loaded. As a result, we have an execution model that's difficult to implement/extend and the behavior is hard to understand.

To move towards the AOT Cache Snapshot Model (JDK-8365645) we should replace the subgraphs with the use of @AOTSafeClassInitializer, and if necessary, @AOTRuntimeSetup. This will simplify the current implementation, and make it possible to extend AOT-initializations to more core classes.

Note, the use of @AOTSafeClassInitializer requires -XX:+AOTClassLinking. For the time being, we retain the old CDS object subgraph code to cover the -XX:-AOTClassLinking cases. Such code will be marked with comments like /* Legacy CDS archive support (to be deprecated) */. All future AOT creation of Java objects will be done with @AOTSafeClassInitializer.


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-8373392: Replace CDS object subgraphs with @AOTSafeClassInitializer (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28736

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 10, 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 Dec 10, 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:

8373392: Replace CDS object subgraphs with @AOTSafeClassInitializer

Reviewed-by: liach

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 6 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 Dec 10, 2025

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

  • core-libs
  • hotspot
  • i18n
  • security

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 Dec 10, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 10, 2025

Webrevs

Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

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

Is IntegerCache.cache the only field that need to be adjusted according to system properties after loading from AOT archive?


@AOTRuntimeSetup
private static void runtimeSetup() {
// to generate a reasonably random and well-mixed SALT, use an arbitrary
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// to generate a reasonably random and well-mixed SALT, use an arbitrary
// to generate a reasonably random and well-mixed SALT, use an arbitrary

@iklam
Copy link
Member Author

iklam commented Dec 10, 2025

Is IntegerCache.cache the only field that need to be adjusted according to system properties after loading from AOT archive?

I think so. The cache size for all other Number types are fixed and cannot be modified by the command-line.

Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

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

The Java code changes look reasonable.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 10, 2025
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.

2 participants