Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Ahead of Time processing in the reference guide #29350

Closed
snicoll opened this issue Oct 19, 2022 · 3 comments
Closed

Document Ahead of Time processing in the reference guide #29350

snicoll opened this issue Oct 19, 2022 · 3 comments
Assignees
Labels
type: documentation A documentation task
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Oct 19, 2022

No description provided.

@sdeleuze
Copy link
Contributor

As discussed in spring-projects/spring-boot#32903, we should add documentation for @ImportRuntimeHints and @RegisterReflectionForBinding that Boot could link.

@santoshgangavaram
Copy link

santoshgangavaram commented Oct 28, 2022

@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

@sdeleuze sdeleuze self-assigned this Nov 2, 2022
@sdeleuze sdeleuze removed their assignment Nov 14, 2022
snicoll added a commit that referenced this issue Nov 14, 2022
@snicoll
Copy link
Member Author

snicoll commented Nov 14, 2022

I've added a section on runtime hints so closing for now.

@snicoll snicoll closed this as completed Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

3 participants