Skip to content

Provide more declarative control over reflection hint registration #29194

Closed
@wilkinsona

Description

@wilkinsona

Affects: 6.0.0-M6

For declarative registration of reflection hints, we currently offer @Reflective and @RegisterReflectionForBinding. These two options, particularly when used at the type level, sit at two opposite ends of the spectrum. @Reflective on a type will register a hint for the type and nothing more. @RegisterReflectionForBinding on a type will register hints for the type, its constructors, fields, properties, and record components for the whole type hierarchy. Sometimes we want something in between. That means you either write your own ReflectiveProcessor or you accept that @RegisterReflectionForBinding will do the job at the cost of some unnecessary hints.

A concrete example of the above can be found in some of Spring Boot's actuator endpoints. We have types that need to be serialised to JSON that can't be discovered by @Reflective at the method level. This can be because a method returns something quite loosely typed like Map<String, Object> or Map<String, Thing> where there are multiple different Thing sub-classes. I'd like to be able to annotate the endpoint type with something that registers additional types for a certain kind of reflection:

@NewReflectionAnnotation(classes = { FirstConcreteThing.class, SecondConcreteThing.class }, memberCategories = INVOKE_PUBLIC_METHODS)

We could take some inspiration from @RegisterForReflection in Quarkus.

Metadata

Metadata

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