Skip to content

[GR-72910] Move registerBuildTimeBootstrapIndy/Condy to the public API - #14254

Merged
graalvmbot merged 1 commit into
masterfrom
scoppey/GR-72910
Aug 25, 2026
Merged

[GR-72910] Move registerBuildTimeBootstrapIndy/Condy to the public API#14254
graalvmbot merged 1 commit into
masterfrom
scoppey/GR-72910

Conversation

@graalvmbot

@graalvmbot graalvmbot commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

This change exposes the existing build-time bootstrap-method registration mechanism through the public Native Image Feature API.

By default, invokedynamic and constantdynamic bootstrap methods are executed at run time. Feature authors can now explicitly allow selected bootstrap methods to execute during image generation:

  • DuringSetupAccess.registerBuildTimeBootstrapIndyExecutable)
  • DuringSetupAccess.registerBuildTimeBootstrapCondy(Executable)

When Native Image encounters an invokedynamic or constantdynamic instruction using a registered bootstrap method, it executes that bootstrap method at build time and constant-folds the resulting call site or dynamic constant into the image. Bootstrap methods that are not registered retain the default run-time behavior.

This is useful for frameworks and language implementations that generate bytecode with custom bootstrap methods and know that those methods are safe and deterministic during image generation.

Usage

Register the bootstrap methods from a Native Image feature during duringSetup:

public final class BuildTimeBootstrapFeature implements Feature {
    @Override
    public void duringSetup(DuringSetupAccess access) {
        try {
            Method indyBootstrap = BootstrapMethods.class.getDeclaredMethod(
                            "indyBootstrap",
                            MethodHandles.Lookup.class,
                            String.class,
                            MethodType.class);

            Method condyBootstrap = BootstrapMethods.class.getDeclaredMethod(
                            "condyBootstrap",
                            MethodHandles.Lookup.class,
                            String.class,
                            Class.class);

            access.registerBuildTimeBootstrapIndy(indyBootstrap);
            access.registerBuildTimeBootstrapCondy(condyBootstrap);
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(e);
        }
    }
}

The feature can then be enabled when building the native image:

native-image --features=com.example.BuildTimeBootstrapFeature ...

Registration does not invoke the method immediately. It allows Native Image to invoke it when a corresponding dynamic call site or constant is encountered. Because any side effects occur during image generation, callers should only register bootstrap methods that are suitable for build-time execution.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 15, 2026
@Zeavee

Zeavee commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@zakkak @dmlloyd,

Regarding #12453 and #12683, there is now a proper API to register bootstrap method that should be executed at build time (through Feature). Please note that FeatureImpl should not be used directly.

Sorry for the delay

@zakkak

zakkak commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the heads up @Zeavee

@graalvmbot graalvmbot changed the title [GR-72910] Move registerBuildTimeIndy/CondyIncludeList to the public API [GR-72910] Move registerBuildTimeBootstrapIndy/Condy to the public API Aug 25, 2026
@graalvmbot
graalvmbot merged commit bb40a4d into master Aug 25, 2026
3 checks passed
@graalvmbot
graalvmbot deleted the scoppey/GR-72910 branch August 25, 2026 10:26
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