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
{{ message }}
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: spring-graalvm-native-docs/src/main/asciidoc/agent.adoc
+1-7Lines changed: 1 addition & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,15 +96,9 @@ GraalVM provides a https://www.graalvm.org/docs/reference-manual/native-image/#i
96
96
----
97
97
====
98
98
99
-
The important part is the `<buildArgs>..</buildArgs>` block that shows the options we pass to the `native-image` operation and the `spring-graalvm-native` feature.
99
+
The important part is the `<configuration><buildArgs>..</buildArgs></configuration>` block that shows the options we pass to the `native-image` operation and the `spring-graalvm-native` feature.
100
100
Those prefixed `-D` are aimed at the feature.
101
101
102
-
NOTE: Notice the `--no-server` option.
103
-
Like a Gradle daemon, the server here is supposed to help accelerate subsequent builds.
104
-
Unfortunately, there is an https://github.com/oracle/graal/issues/1952[issue] where the server causes different results to come out of the compilation.
105
-
In particular, we have seen logging disappear the server is used to aid compilation.
106
-
Hence, using the server to aid compilation is turned off here.
107
-
108
102
===== Add the repository for `spring-graalvm-native`
109
103
110
104
If necessary, add the repository for the `spring-graalvm-native` dependency, as follows:
Copy file name to clipboardExpand all lines: spring-graalvm-native-docs/src/main/asciidoc/extension_guide.adoc
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,8 @@ Each of these hints specifies a set of types that need accessibility, what kind
21
21
22
22
These `@NativeImageHint` should be hosted in one of two places.
23
23
24
-
First, in the `spring-graalvm-native-configuration` module, you can see that they are hosted on types that implement the `org.springframework.graal.extension.NativeImageConfiguration` interface (defined by the feature).
25
-
Implementations of this interface should be listed in a `src/main/resources/META-INF/services/org.springframework.graal.extension.NativeImageConfiguration` file, which the feature loads through regular Java service loading.
24
+
First, in the `spring-graalvm-native-configuration` module, you can see that they are hosted on types that implement the `org.springframework.graalvm.extension.NativeImageConfiguration` interface (defined by the feature).
25
+
Implementations of this interface should be listed in a `src/main/resources/META-INF/services/org.springframework.graalvm.extension.NativeImageConfiguration` file, which the feature loads through regular Java service loading.
26
26
27
27
Second, they can be put directly onto Spring configuration classes, and they are picked up by the feature.
28
28
@@ -73,9 +73,9 @@ The feature also chases down references between configurations (`@Import`) and l
73
73
74
74
This means that, for any application, there is some 'tree' of configurations active with hints scattered across them.
75
75
76
-
=== Structure of the `spring-boot-graal-configuration` module
76
+
=== Structure of the `spring-graalvm-native-configuration` module
77
77
78
-
In the `spring-boot-graal-configuration`, numerous package names look like Spring package names.
78
+
In the `spring-graalvm-native-configuration`, numerous package names look like Spring package names.
79
79
That is deliberate.
80
80
Notice the use of direct class references in the hints rather than strings.
81
81
This type safety is a little more robust.
@@ -111,7 +111,7 @@ If you are using a piece of Spring we don't have a sample for, this is likely to
111
111
Usually, we do a few searches for references to the type that is missing, and those searches guide us to the configuration.
112
112
113
113
. If there is already a `NativeImageConfiguration` implementation for that configuration, augment it with the extra type info.
114
-
If there is not, create one and attach a `@NativeImageHint` to it, to identify the triggering configuration and the classes that need to be exposed.
114
+
If there is not, create one, attach a `@NativeImageHint` to it to identify the triggering configuration and the classes that need to be exposed, and add it to the `META-INF/services/org.springframework.graalvm.extension.NativeImageConfiguration` .
115
115
You also need to set the accessibility in the annotation (in the `@TypeInfo`).
116
116
It is possible that more dependencies may need to be added to the configuration project to allow the direct class references.
117
117
That is OK, so long as you ensure that they are provided scope.
Copy file name to clipboardExpand all lines: spring-graalvm-native-docs/src/main/asciidoc/hybrid_feature_agent.adoc
+1-13Lines changed: 1 addition & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,19 +91,7 @@ Paste the following XML into the `pom.xml` file (we use it later to invoke the n
91
91
----
92
92
====
93
93
94
-
The important part is the `<buildArgs>..</buildArgs>` block that shows the options we are passing to the `native-image` operation and the `spring-graalvm-native` feature.
95
-
Those prefixed `-D` are aimed at the feature.
96
-
97
-
NOTE: Notice the `--no-server` option.
98
-
Like a Gradle daemon, the server here is supposed to help accelerate subsequent builds.
99
-
Unfortunately, there is an https://github.com/oracle/graal/issues/1952[issue] where the server causes different results to come out of the compilation.
100
-
In particular, we have seen logging disappear if the server is used to aid compilation.
101
-
Hence using the server to aid compilation is turned off here.
102
-
103
-
We can use the `-Dspring.native.remove-unused-autoconfig=true` option to evaluate some of the Spring Boot conditions at image-build time.
104
-
For example, it applies to `@ConditionalOnClass`.
105
-
Because `native-image` runs at a point when the full classpath is known, we can know for certain if a class is around.
106
-
If it is not around, the auto-configuration conditional on that class can be discarded and not have an impact on the image startup. More details on options are discussed <<options,here>>.
94
+
You can specify additional <<options>> via a `<configuration><buildArgs>..</buildArgs></configuration>` block.
107
95
108
96
===== Add the repository for `spring-graalvm-native`
Copy file name to clipboardExpand all lines: spring-graalvm-native-docs/src/main/asciidoc/troubleshooting.adoc
+2-47Lines changed: 2 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,48 +19,9 @@ The image can fail for a number of reasons. We have described the most common ca
19
19
20
20
==== Out of memory error when building the native image
21
21
22
-
`native-image` consumes a lot of RAM.
23
-
We have most success on 32G RAM desktop machines.
22
+
`native-image` consumes a lot of RAM. We have most success on 32G RAM desktop machines.
24
23
16G is possible for smaller samples but 8G machines are likely to hit problems more often.
25
-
26
-
==== You get a weird crash
27
-
28
-
If you get a "`weird crash`", check to see if you get the following error:
29
-
30
-
====
31
-
[source,bash]
32
-
----
33
-
Exception during JVMCI compiler initialization:
34
-
Exception in thread "main": java.lang.ExceptionInInitializerError
35
-
java.lang.ExceptionInInitializerError
36
-
at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:290)
37
-
at java.lang.Class.ensureInitialized(DynamicHub.java:496)
38
-
at java.lang.System.getenv(System.java:897)
39
-
at org.graalvm.libgraal.jni.JNIUtil.traceLevel(JNIUtil.java:268)
40
-
at org.graalvm.libgraal.jni.JNIUtil.trace(JNIUtil.java:292)
41
-
at org.graalvm.libgraal.jni.HotSpotToSVMScope.<init>(HotSpotToSVMScope.java:114)
42
-
at org.graalvm.compiler.hotspot.management.libgraal.HotSpotGraalManagement.defineClassesInHotSpot(HotSpotGraalManagement.java:170)
43
-
at org.graalvm.compiler.hotspot.management.libgraal.HotSpotGraalManagement.initialize(HotSpotGraalManagement.java:115)
44
-
at org.graalvm.compiler.hotspot.HotSpotGraalRuntime.<init>(HotSpotGraalRuntime.java:178)
45
-
at org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:156)
46
-
at org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:134)
47
-
at org.graalvm.compiler.hotspot.HotSpotGraalCompilerFactory.createCompiler(HotSpotGraalCompilerFactory.java:52)
48
-
at jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.getCompiler(HotSpotJVMCIRuntime.java:599)
49
-
at jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.compileMethod(HotSpotJVMCIRuntime.java:667)
50
-
at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST_Nonvirtual:Ljdk_vm_ci_hotspot_HotSpotJVMCIRuntime_2_0002ecompileMethod_00028Ljdk_vm_ci_hotspot_HotSpotResolvedJavaMethod_2IJI_00029Ljdk_vm_ci_hotspot_HotSpotCompilationRequestResult_2(JNIJavaCallWrappers.java:0)
51
-
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 83 out of bounds for length 82
52
-
at com.oracle.svm.jni.functions.JNIFunctions.SetObjectArrayElement(JNIFunctions.java:683)
53
-
at java.lang.ProcessEnvironment.environ(ProcessEnvironment.java)
54
-
at java.lang.ProcessEnvironment.<clinit>(ProcessEnvironment.java:70)
55
-
at com.oracle.svm.core.hub.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:350)
56
-
at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:270)
57
-
... 14 more
58
-
Error: Image build request failed with exit status 255
59
-
----
60
-
====
61
-
62
-
This has been seen with Graal 20.0.
63
-
The current workaround is to re-run your application, because the problem is intermittent.
24
+
You can use `-H:+RemoveSaturatedTypeFlows` `native-image` option to reduce the amount of memory required.
64
25
65
26
=== The built image does not run
66
27
@@ -140,12 +101,6 @@ Currently it will warn about failing to specify `proxyBeanMethods=false` on comp
140
101
there now to take it further than that as we observe common problems that could be more aggressively checked
141
102
earlier.
142
103
143
-
=== Where has my logging gone?
144
-
145
-
In standard operation, `native-image` uses a server to optimize compilation speeds.
146
-
Using the server has been known to produce native images that are missing logging.
147
-
In this case, add `--no-server` to the arguments being passed to `native-image`.
148
-
149
104
==== No access hint found for import selector: XXX
150
105
151
106
The feature chases down configuration references to other configurations (`@Import` usages).
0 commit comments