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
|[**jdk-ee**](https://container-registry.oracle.com/ords/ocr/ba/graalvm/jdk-ee)| A compact image containing the GraalVM Enterprise JDK. |
17
-
|[**native-image-ee**](https://container-registry.oracle.com/ords/ocr/ba/graalvm/native-image-ee)| A compact image which includes the GraalVM Enterprise `native-image` utility and JDK |
18
-
|[**enterprise**](https://container-registry.oracle.com/ords/ocr/ba/graalvm/enterprise)| Provides the GraalVM Enterprise JDK along with the `gu` (Graal Updater) utility to enable installation of additional features. |
19
-
|[**nodejs-ee**](https://container-registry.oracle.com/ords/ocr/ba/graalvm/nodejs-ee)| Includes the Node.js runtime and the GraalVM Enterprise JDK. |
16
+
|**jdk-ee**| A compact image containing the GraalVM Enterprise JDK. |
17
+
|**native-image-ee**| A compact image which includes the GraalVM Enterprise `native-image` utility and JDK |
18
+
|**enterprise**| Provides the GraalVM Enterprise JDK along with the `gu` (Graal Updater) utility to enable installation of additional features. |
19
+
|**nodejs-ee**| Includes the Node.js runtime and the GraalVM Enterprise JDK. |
The GraalVM Polyglot API lets you embed and run code from guest languages in JVM-based host applications.
@@ -492,7 +491,7 @@ public class Main {
492
491
}
493
492
```
494
493
495
-
In this code:
494
+
In this code:
496
495
-`import org.graalvm.polyglot.*` imports the base API for the Polyglot API.
497
496
-`Engine.create()` creates a new engine instance with the default configuration.
498
497
-`Source.create()` creates a source object for the expression “21 + 21”
@@ -532,7 +531,7 @@ public class Main {
532
531
}
533
532
```
534
533
535
-
In this code:
534
+
In this code:
536
535
-`Context.newBuilder().allowAllAccess(true).build()` builds a new outer context with all privileges.
537
536
-`outer.eval` evaluates a JavaScript snippet in the outer context.
538
537
-`inner = Java.type('org.graalvm.polyglot.Context').create()` the first JS script line looks up the Java host type Context and creates a new inner context instance with no privileges (default).
@@ -610,9 +609,6 @@ In this code:
610
609
- The `context.eval()` call evaluates a specified snippet of guest language code.
611
610
- The `listener.close()` closes a listener earlier, however execution listeners are automatically closed with the engine.
612
611
613
-
<!-- Enterprise Sandbox Resource Limits -->
614
-
{% include_relative sandbox-options.md %}
615
-
616
612
## Polyglot Isolates
617
613
618
614
On GraalVM Enterprise, a Polyglot engine can be configured to run in a dedicated native image isolate.
By default, the native image builder will not integrate any of the resources which are on the classpath during the generation into the final image.
10
-
To make calls such as `Class.getResource()` or `Class.getResourceAsStream()` (or the corresponding ClassLoader methods) return specific resources (instead of null), the resources that should be accessible at image run time need to be explicitly specified. This can be done via a configuration file such as the following:
9
+
By default, the `native-image` tool will not integrate any of the resources which are on the classpath during the generation into the final image.
10
+
To make calls such as `Class.getResource()` or `Class.getResourceAsStream()` (or their corresponding `ClassLoader` methods) return specific resources (instead of `null`), you must specify the resources that should be accessible at run time.
11
+
This can be achieved using a configuration file with the following content:
11
12
12
13
```json
13
14
{
@@ -30,11 +31,11 @@ The configuration file's path must be provided to `native-image` with `-H:Resour
30
31
Alternatively, individual resource paths can also be specified directly to `native-image`:
31
32
32
33
```shell
33
-
native-image -H:IncludeResources=<Java regexp that matches resources to be included in the image> -H:ExcludeResources=<Java regexp that matches resources to be excluded from the image> ...
34
+
native-image -H:IncludeResources="<Java regexp that matches resources to be included in the image>" -H:ExcludeResources="<Java regexp that matches resources to be excluded from the image>" ...
34
35
```
35
36
The `-H:IncludeResources` and `-H:ExcludeResources` options can be passed several times to define more than one regexp to match or exclude resources, respectively.
36
37
37
-
To see which resources get ultimately included into the image, you can enable the related logging info with `-H:Log=registerResource:`.
38
+
To see which resources are included in the native executable, use the option `-H:Log=registerResource:<log level>`. The `<log level>` must be in the range from `1` to `5`, from least detailed to most detailed.
38
39
39
40
### Example Usage
40
41
@@ -52,11 +53,73 @@ my-app-root
52
53
```
53
54
Then:
54
55
55
-
* All resources can be loaded with `.*/Resource.*txt$`, specified as `{"pattern":".*/Resource.*txt$"}` in a configuration file, or `-H:IncludeResources='.*/Resource.*txt$'` on the command line.
56
+
* All resources can be loaded with `".*/Resource.*txt$"`, specified as `{"pattern":".*/Resource.*txt$"}` in a configuration file, or `-H:IncludeResources=".*/Resource.*txt$"` on the command line.
56
57
*`Resource0.txt` can be loaded with `.*/Resource0.txt$`.
57
58
*`Resource0.txt` and `Resource1.txt` can be loaded with `.*/Resource0.txt$` and `.*/Resource1.txt$`
58
59
(or alternatively with a single `.*/(Resource0|Resource1).txt$`).
59
-
* Also, if we want to include everything except the `Resource2.txt` file, we can simply exclude it with `-H:IncludeResources='.*/Resource.*txt$'` followed by `-H:ExcludeResources='.*/Resource2.txt$'`.
60
+
* Also, if we want to include everything except the `Resource2.txt` file, we can simply exclude it with `-H:IncludeResources=".*/Resource.*txt$"` followed by `-H:ExcludeResources=".*/Resource2.txt$"`.
61
+
62
+
The following demo illustrates how to include a resource into a native executable. The application `fortune` simulates the traditional `fortune` Unix program (for more information, see [fortune](https://en.wikipedia.org/wiki/Fortune_(Unix)).
63
+
64
+
1. Save the following Java code into the _Fortune.java_ file:
See also the [guide on assisted configuration of Java resources and other dynamic features](BuildConfiguration.md#assisted-configuration-of-native-image-builds).
62
125
@@ -94,7 +157,7 @@ Alternatively, bundles can be specified directly as options to `native-image` as
By default, the requested bundles are included for all requested locales.
97
-
In order to optimize this, it is possible to use ``IncludeResourceBundles`` with locale specific substring, for example ``-H:+IncludeResourceBundles=com.company.bundles.MyBundle_fr-FR`` will include the bundle only in French.
160
+
In order to optimize this, it is possible to use `IncludeResourceBundles` with locale specific substring, for example `-H:+IncludeResourceBundles=com.company.bundles.MyBundle_fr-FR` will include the bundle only in French.
98
161
99
162
### Resources in Java modules
100
163
@@ -124,6 +187,6 @@ will always work as expected for resources registered as described above (even i
124
187
### JVM Mode of Localization
125
188
126
189
Resource Bundle lookup is a complex and dynamic mechanism which utilizes a lot of the infrastructure of JVM.
127
-
As a result of that, it causes image size increase for smaller applications such as Hello World.
190
+
As a result of that, it causes the size of the executable to increase for smaller applications such as `HelloWorld`.
128
191
Therefore, an optimized mode is set by default in which this lookup is simplified utilizing the fact the all bundles are known ahead of time.
129
192
In case you would like to use the original JVM lookup, use the `-H:-LocalizationOptimizedMode` option.
0 commit comments