You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: framework-docs/src/docs/asciidoc/core/core-aot.adoc
+12-13Lines changed: 12 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ This chapter covers Spring's Ahead of Time (AOT) optimizations.
5
5
6
6
For AOT support specific to integration tests, see <<testing.adoc#testcontext-aot, Ahead of Time Support for Tests>>.
7
7
8
-
[[aot-introduction]]
8
+
[[core.aot.introduction]]
9
9
== Introduction to Ahead of Time Optimizations
10
10
11
11
Spring's support for AOT optimizations is meant to inspect an `ApplicationContext` at build time and apply decisions and discovery logic that usually happens at runtime.
@@ -263,30 +263,29 @@ The following example registers `Account` for serialization.
263
263
[[core.aot.hints.testing]]
264
264
=== Testing Runtime Hints
265
265
266
-
Spring Core also ships `RuntimeHintsPredicates`, an utility for checking that existing hints match a particular use case.
267
-
This can be used in your own tests, for validating that a `RuntimeHintsRegistrar` has the expected result.
268
-
We can write a test for our `SpellCheckService` and ensure that we can load a dictionary at runtime:
266
+
Spring Core also ships `RuntimeHintsPredicates`, a utility for checking that existing hints match a particular use case.
267
+
This can be used in your own tests to validate that a `RuntimeHintsRegistrar` contains the expected results.
268
+
We can write a test for our `SpellCheckService` and ensure that we will be able to load a dictionary at runtime:
With `RuntimeHintsPredicates`, we can check for reflection, resource, serialization or proxy generation hints.
272
+
With `RuntimeHintsPredicates`, we can check for reflection, resource, serialization, or proxy generation hints.
273
273
This approach works well for unit tests but implies that the runtime behavior of a component is well known.
274
274
275
275
You can learn more about the global runtime behavior of an application by running its test suite (or the app itself) with the {docs-graalvm}/native-image/metadata/AutomaticMetadataCollection/[GraalVM tracing agent].
276
276
This agent will record all relevant calls requiring GraalVM hints at runtime and write them out as JSON configuration files.
277
277
278
278
For more targeted discovery and testing, Spring Framework ships a dedicated module with core AOT testing utilities, `"org.springframework:spring-core-test"`.
279
-
This module contains the RuntimeHints Agent, a Java agent that all method invocations that are related to runtime hints and helps you to assert that a given `RuntimeHints` instance covers all recorded invocations.
280
-
Let's consider a piece of infrastructure for which we'd like to test the hints we're contributing during the AOT phase.
281
-
279
+
This module contains the RuntimeHints Agent, a Java agent that records all method invocations that are related to runtime hints and helps you to assert that a given `RuntimeHints` instance covers all recorded invocations.
280
+
Let's consider a piece of infrastructure for which we'd like to test the hints we're contributing during the AOT processing phase.
282
281
283
282
include::code:SampleReflection[]
284
283
285
-
We can then write a Java test (no native compilation required!) that checks our contributed hints:
284
+
We can then write a unit test (no native compilation required) that checks our contributed hints:
286
285
287
286
include::code:SampleReflectionRuntimeHintsTests[]
288
287
289
-
If you forgot to contribute a hint, the test will fail and give some details on the invocation:
288
+
If you forgot to contribute a hint, the test will fail and provide some details about the invocation:
290
289
291
290
[source,txt,indent=0,subs="verbatim,quotes"]
292
291
----
@@ -303,6 +302,6 @@ io.spring.runtimehintstesting.SampleReflection#performReflection, Line 19
303
302
io.spring.runtimehintstesting.SampleReflectionRuntimeHintsTests#lambda$shouldRegisterReflectionHints$0, Line 25
304
303
----
305
304
306
-
There are various ways to configure this Java agent into your build, please refer to your build tool and test execution plugin documentation.
307
-
The agent itself can be configured to instrument some packages (by default, only `org.springframework` is instrumented).
308
-
You'll find more details in the https://github.com/spring-projects/spring-framework/blob/main/buildSrc/README.md[Spring Framework buildSrc README].
305
+
There are various ways to configure this Java agent in your build, so please refer to the documentation of your build tool and test execution plugin.
306
+
The agent itself can be configured to instrument specific packages (by default, only `org.springframework` is instrumented).
307
+
You'll find more details in the {spring-framework-main-code}/buildSrc/README.md[Spring Framework `buildSrc` README] file.
Copy file name to clipboardExpand all lines: framework-docs/src/main/java/org/springframework/docs/core/aot/hints/testing/SampleReflectionRuntimeHintsTests.java
0 commit comments