Review reachability metadata contributions after GraalVM changes #31213
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.
- Fix RuntimeHintsPredicates matching rules for public/declared elements #31224
- Reduce nested class lookups in ClassUtils #31258
- Missing reflection hints for jakarta.inject classes #31259
- Missing reflection hint on MonetaryAmount in conversion service #31266
- Missing reflection hints on Kotlin classes for KotlinDetector #31269
- Missing resource hint for spring.properties #31270
- Missing reflection hint on Publisher for bean destroy methods support #31278
- AOT bean registrations miss reflection hints on public methods #31293
- AOT bean registrations miss reflection hints on interfaces #31350
- AOT bean registrations miss reflection hints on property fields #31390