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

Review reachability metadata contributions after GraalVM changes #31213

Closed
bclozel opened this issue Sep 13, 2023 · 1 comment
Closed

Review reachability metadata contributions after GraalVM changes #31213

bclozel opened this issue Sep 13, 2023 · 1 comment
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Sep 13, 2023

The GraalVM team has been working on reporting missing reachability metadata as exceptions at runtime. Relevant changes have been contributed to recent builds with oracle/graal#7179 or oracle/graal#6139.

These changes will bring more predictability and consistency when it comes to reachability metadata, as discussed in the proposal. Metadata produced by Spring should be complete and avoid relying on unspecified behavior of the native-image at runtime.

Running a Spring application with a GraalVM dev build and the following options:

graalvmNative {
    binaries {
        main {
            quickBuild = true
            buildArgs.add('-H:+UnlockExperimentalVMOptions') // see https://github.com/oracle/graal/issues/7105
            buildArgs.add('-H:ThrowMissingRegistrationErrors=')
            buildArgs.add('-H:MissingRegistrationReportingMode=Warn')
        }
    }
}

will show warnings in the logs, such as:

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer.getConstructors() without it being registered for runtime reflection. Add org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer.getConstructors() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
  java.base@21/java.lang.Class.getConstructors(DynamicHub.java:1010)
  org.springframework.core.io.support.SpringFactoriesLoader$FactoryInstantiator.findConstructor(SpringFactoriesLoader.java:405)
  org.springframework.core.io.support.SpringFactoriesLoader$FactoryInstantiator.forClass(SpringFactoriesLoader.java:394)
  org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:227)

This is an umbrella issue that will track efforts in the Spring Framework to fix and update the reachability metadata produced during the AOT phase to prepare for the upcoming GraalVM release. Dedicated issues and PRs will be created against other Spring projects if needed. For 3rd party dependencies, we'll turn to the reachability metadata repository.

@bclozel
Copy link
Member Author

bclozel commented Nov 16, 2023

Closing this umbrella issue as a first round of improvements. We will refine this with further changes in 6.1.x if needed, as soon as new GraalVM dev builds are shipped with relevant changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant