From bebdf69552e29b7c7e60eb1e2bba746346af0bb4 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 8 Nov 2024 11:27:21 +0000 Subject: [PATCH] Document how to statically provide GraalVM hints Closes gh-42515 --- .../docs/asciidoc/native-image/advanced-topics.adoc | 11 ++++++++++- .../introducing-graalvm-native-images.adoc | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/advanced-topics.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/advanced-topics.adoc index e1735662d94d..5956a1b00798 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/advanced-topics.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/advanced-topics.adoc @@ -150,7 +150,7 @@ For further reading, please see {graal-native-image-docs}/metadata/AutomaticMeta [[native-image.advanced.custom-hints]] === Custom Hints -If you need to provide your own hints for reflection, resources, serialization, proxy usage etc. you can use the `RuntimeHintsRegistrar` API. +If you need to provide your own hints for reflection, resources, serialization, proxy usage and so on, you can use the `RuntimeHintsRegistrar` API. Create a class that implements the `RuntimeHintsRegistrar` interface, and then make appropriate calls to the provided `RuntimeHints` instance: include::code:MyRuntimeHints[] @@ -172,6 +172,15 @@ include::code:MyRuntimeHintsTests[] +[[native-image.advanced.custom-hints.static]] +==== Providing Hints Statically +If you prefer, custom hints can be provided statically in one or more GraalVM JSON hint files. +Such files should be placed in `src/main/resources/` within a `+META-INF/native-image/*/*/+` directory. +The <> are written to a directory named `+META-INF/native-image/{groupId}/{artifactId}/+`. +Place your static hint files in a directory that does not clash with this location, such as `+META-INF/native-image/{groupId}/{artifactId}-additional-hints/+` + + + [[native-image.advanced.known-limitations]] === Known Limitations GraalVM native images are an evolving technology and not all libraries provide support. diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/introducing-graalvm-native-images.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/introducing-graalvm-native-images.adoc index bacc73c71301..06f4a2aa49f2 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/introducing-graalvm-native-images.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/introducing-graalvm-native-images.adoc @@ -53,13 +53,15 @@ A Spring AOT processed application will typically generate: * Java source code * Bytecode (for dynamic proxies etc) -* GraalVM JSON hint files: +* GraalVM JSON hint files in `+META-INF/native-image/{groupId}/{artifactId}/+`: - Resource hints (`resource-config.json`) - Reflection hints (`reflect-config.json`) - Serialization hints (`serialization-config.json`) - Java Proxy Hints (`proxy-config.json`) - JNI Hints (`jni-config.json`) +If the generated hints are not sufficient, you can also <>. + [[native-image.introducing-graalvm-native-images.understanding-aot-processing.source-code-generation]]