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

[GR-49525] Mechanism to move JDK initialization to run time. #10531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

graalvmbot
Copy link
Collaborator

@graalvmbot graalvmbot commented Jan 21, 2025

We are reducing build-time initialization of the JDK in following GraalVM versions. This means that many substitutions for run-time-initialized parts of the JDK will not be needed anymore.

Problems:

  1. If previously initialized classes end up in the image heap of user code, they will break the build.
  2. The projects that build-time initialize the whole world will need the JDK substitutions.

How to avoid code breakage

We introduce -H:+InitializeJDKAtBuildTimeMigration that will keep the previous initialization functionality. This flag will simply enable a feature that build-time initializes the same set of classes as the previous GraalVM versions.

The build-time initialization error message would be augmented with a note that they can use the previous behavior with -H:+InitializeJDKAtBuildTimeMigration until they introduce all required -initialize-at-build-time=<class>.

How to support build-time initialized projects

Introduce a separate package for build-time initialization substitutions and make them available only if the class is initialized at build time.

This will require a slight change in the way we handle TargetClass:

@TargetClass(value = java.lang.SecurityManager.class, onlyWith = MarkedAsBuildTimeInitialized.class)

If needed we will provide an API for markedAsBuildTimeInitialized in RuntimeClassInitialization.

This package will be maintained by the GraalVM team until the JDK initialization minimization is complete. After that, it would be handed over for maintenance to the community.

The same package would be moved into a spearate community maintained project when we remove -H:+MigrationInitializeJDKAtBuildTime.

Example usage: #10537

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jan 21, 2025
@graalvmbot graalvmbot force-pushed the vj/GR-49525-run-time-jdk-support branch from 042504c to 1e04cbe Compare January 22, 2025 13:02
@jerboaa
Copy link
Collaborator

jerboaa commented Jan 22, 2025

@vjovanov Could you please add a description to this PR? It shows up empty over here :-/

The -H:+InitializeJDKAtBuildTimeMigration flag is used in GraalVM 25+
to revert the initialization of the JDK to the state from GraalVM 24-.

This flag is only a temporary mesaure until project adjust their
build-time initialization configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants