Skip to content

Adopt new GraalVM reachability metadata format #33847

Closed
@bclozel

Description

@bclozel

As of Spring Framework 7.0, we should completely adopt the new GraalVM reachability metadata format. This format has been simplified and now has a dedicated JSON schema.

There are a few notable behavior changes.

The registration of resources has changed, this is already described in a separate issue, see #31340.

The metadata conditions have changed from "typeReachable" from "typeReached". Previously, "typeReachable" would imply that a type is reachable through static analysis. This depends too much on the capabilities of the static analysis and can be hard to predict. Instead, "typeReached" means that the type "A type is reached at run time, right before the class-initialization routine starts for that type (class or interface), or any of the type’s subtypes are reached." This changes the metadata format but shouldn't change much for our support. This would only affect projects and apps that use a condition with a type that is not strictly initialized, like an interface.

The metadata for proxy generation is now part of the reflection metadata. This doesn't change our RuntimeHints API but we should adapt our JSON serialization format accordingly.

Several convenience reflection flags have been removed. "allDeclaredConstructors", "allPublicConstructors", "allDeclaredMethods", "allPublicMethods" enable reflective invocation of constructors and methods, and are still supported. "queryAllPublicConstructors", "queryAllDeclaredConstructors", "queryAllPublicMethods", "queryAllDeclaredMethods", "allPublicClasses", "allDeclaredClasses" enable reflective introspection and have been removed since this is now done automatically as soon as a reflection metadata entry is added for the declaring type. As a result, several parts of our RuntimeHints will be made useless; we should decide whether we want to deprecate it or just ignore its results during the JSON metadata generation.

We can test the new reachability behavior by using a VM option:

To get an overview of all places in your code where missing registrations occur, without committing to the exact behavior, you can pass -XX:MissingRegistrationReportingMode=Warn when starting the application.

To detect places where the application accidentally ignores a missing registration error (with catch (Throwable t) blocks), pass -XX:MissingRegistrationReportingMode=Exit when starting the application. The application will then unconditionally print the error message with the stack trace and exit immediately. This behavior is ideal for running application tests to guarantee all metadata is included.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)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