Comment From: sdeleuze
As discussed in spring-projects/spring-boot#32903, we should add documentation for @ImportRuntimeHints
and @RegisterReflectionForBinding
that Boot could link.
Comment From: santoshgangavaram
@sdeleuze Would this be good to add in core-aot.adoc at the end to highlight about RegisterReflectionForBinding and ImportRuntimeHints annotations?
Custom Hints
If you need to provide your own hints for reflection, resources, serialization, proxy usage etc. you can use the RuntimeHintsRegistrar API. Create a class that implements the RuntimeHintsRegistrar interface, then make appropriate calls to the provided RuntimeHints instance:
code:MyRuntimeHints
You can then use @ImportRuntimeHints on any @Configuration class (for example your @SpringBootApplication annotated application class) to activate those hints.
If you have classes which needs binding (mostly needed when serializing or deserializing JSON), you can use @RegisterReflectionForBinding on any bean. Most of the hints are automatically inferred, for example when accepting or returning data from a @RestController method. But when you work with WebClient or RestTemplate directly, you might need to use RegisterReflectionForBinding:
code:JsonSerialization
Testing custom hints
The RuntimeHintsPredicates API can be used to test your hints. The API provides methods that build a Predicate that can be used to test a RuntimeHints instance.
If you’re using AssertJ, your test would look like this:
code:MyRuntimeHintsTests
Comment From: snicoll
I've added a section on runtime hints so closing for now.