Skip to content

Review reachability metadata contributions after GraalVM changes #31213

Closed
@bclozel

Description

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.

Metadata

Assignees

Labels

theme: aotAn issue related to Ahead-of-time processingtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions