Skip to content

Commit b1f7d42

Browse files
committed
docs/reference-manual/native-image update ref links to rel paths; start sentences from a new line
1 parent 7d272da commit b1f7d42

16 files changed

+256
-326
lines changed

docs/reference-manual/native-image/Agent.md

Lines changed: 56 additions & 38 deletions
Large diffs are not rendered by default.

docs/reference-manual/native-image/BuildConfiguration.md

Lines changed: 41 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,17 @@ Native Image supports a wide range of options to configure a native image build
1818

1919
## Embedding a Configuration File
2020

21-
A recommended way to provide configuration is to embed a
22-
**native-image.properties** file into a project JAR file. The Native Image builder
23-
will automatically pick up all configuration options provided anywhere below the
24-
resource location `META-INF/native-image/` and use it to construct
25-
`native-image` command line arguments.
26-
27-
To avoid a situation when constituent parts of a project are built
28-
with overlapping configurations, it is recommended to use "subdirectories" within
29-
`META-INF/native-image`. That way a JAR file built from multiple maven projects
30-
cannot suffer from overlapping `native-image` configurations. For example:
21+
A recommended way to provide configuration is to embed a **native-image.properties** file into a project JAR file.
22+
The Native Image builder will automatically pick up all configuration options provided anywhere below the resource location `META-INF/native-image/` and use it to construct `native-image` command line arguments.
23+
24+
To avoid a situation when constituent parts of a project are built with overlapping configurations, it is recommended to use "subdirectories" within `META-INF/native-image`.
25+
That way a JAR file built from multiple maven projects cannot suffer from overlapping `native-image` configurations.
26+
For example:
3127
* _foo.jar_ has its configurations in `META-INF/native-image/foo_groupID/foo_artifactID`
3228
* _bar.jar_ has its configurations in `META-INF/native-image/bar_groupID/bar_artifactID`
3329

34-
The JAR file that contains `foo` and `bar` will then contain both configurations
35-
without conflicting with one another. Therefore the recommended layout for
36-
storing native image configuration data in JAR files is the following:
30+
The JAR file that contains `foo` and `bar` will then contain both configurations without conflicting with one another.
31+
Therefore the recommended layout for storing native image configuration data in JAR files is the following:
3732
```
3833
META-INF/
3934
└── native-image
@@ -42,12 +37,9 @@ META-INF/
4237
└── native-image.properties
4338
```
4439

45-
Note that the use of `${.}` in a _native-image.properties_ file expands to the
46-
resource location that contains that exact configuration file. This can be
47-
useful if the _native-image.properties_ file wants to refer to resources within
48-
its "subfolder", for example, `-H:SubstitutionResources=${.}/substitutions.json`.
49-
Always make sure to use the option variants that take resources, i.e., use
50-
`-H:ResourceConfigurationResources` instead of `-H:ResourceConfigurationFiles`.
40+
Note that the use of `${.}` in a _native-image.properties_ file expands to the resource location that contains that exact configuration file.
41+
This can be useful if the _native-image.properties_ file wants to refer to resources within its "subfolder", for example, `-H:SubstitutionResources=${.}/substitutions.json`.
42+
Always make sure to use the option variants that take resources, i.e., use `-H:ResourceConfigurationResources` instead of `-H:ResourceConfigurationFiles`.
5143
Other options that are known to work in this context are:
5244
* `-H:DynamicProxyConfigurationResources`
5345
* `-H:JNIConfigurationResources`
@@ -56,16 +48,14 @@ Other options that are known to work in this context are:
5648
* `-H:SubstitutionResources`
5749
* `-H:SerializationConfigurationResources`
5850

59-
By having such a composable _native-image.properties_ file, building an image
60-
does not require any additional arguments specified on command line. It is
61-
sufficient to just run the following command:
51+
By having such a composable _native-image.properties_ file, building an image does not require any additional arguments specified on command line.
52+
It is sufficient to just run the following command:
6253
```shell
6354
$JAVA_HOME/bin/native-image -jar target/<name>.jar
6455
```
6556

66-
To debug which configuration data gets applied for the image building, use `native-image --verbose`. This will show from where `native-image` picks up the
67-
configurations to construct the final composite configuration command line
68-
options for the native image builder.
57+
To debug which configuration data gets applied for the image building, use `native-image --verbose`.
58+
This will show from where `native-image` picks up the configurations to construct the final composite configuration command line options for the native image builder.
6959
```shell
7060
native-image --verbose -jar build/basic-app-0.1-all.jar
7161
Apply jar:file://~/build/basic-app-0.1-all.jar!/META-INF/native-image/io.netty/common/native-image.properties
@@ -89,44 +79,38 @@ supported.
8979

9080
**Args**
9181

92-
Use this property if your project requires custom `native-image` command line options to build correctly. For example, the `native-image-configure-examples/configure-at-runtime-example` has `Args = --initialize-at-build-time=com.fasterxml.jackson.annotation.JsonProperty$Access` in its `native-image.properties` file to ensure the class `com.fasterxml.jackson.annotation.JsonProperty$Access` gets initialized at image build time.
82+
Use this property if your project requires custom `native-image` command line options to build correctly.
83+
For example, the `native-image-configure-examples/configure-at-runtime-example` has `Args = --initialize-at-build-time=com.fasterxml.jackson.annotation.JsonProperty$Access` in its `native-image.properties` file to ensure the class `com.fasterxml.jackson.annotation.JsonProperty$Access` gets initialized at image build time.
9384

9485
**JavaArgs**
9586

96-
Sometimes it can be necessary to provide custom options to the JVM that runs the
97-
native image builder. The `JavaArgs` property can be used in this case.
87+
Sometimes it can be necessary to provide custom options to the JVM that runs the native image builder.
88+
The `JavaArgs` property can be used in this case.
9889

9990
**ImageName**
10091

101-
This property can be used to specify a user-defined name for the image. If
102-
`ImageName` is not used, a name gets automatically chosen:
92+
This property can be used to specify a user-defined name for the image.
93+
If `ImageName` is not used, a name gets automatically chosen:
10394
* `native-image -jar <name.jar>` has a default image name `<name>`
10495
* `native-image -cp ... fully.qualified.MainClass` has a default image name `fully.qualified.mainclass`
10596

106-
Note that using `ImageName` does not prevent the user to override the name later via command line. For example, if `foo.bar` contains `ImageName=foo_app`:
97+
Note that using `ImageName` does not prevent the user to override the name later via command line.
98+
For example, if `foo.bar` contains `ImageName=foo_app`:
10799
* `native-image -jar foo.bar` generates the image `foo_app` but
108100
* `native-image -jar foo.bar application` generates the image `application`
109101

110102
### Order of Arguments Evaluation
111-
The arguments passed to `native-image` are evaluated left-to-right. This also
112-
extends to arguments that get passed indirectly via `META-INF/native-image`
113-
based native image configuration. Suppose you have a JAR file that contains
114-
_native-image.properties_ with `Args = -H:Optimize=0`. Then by using the
115-
`-H:Optimize=2` option after `-cp <jar-file>` you can override the setting that
116-
comes from the JAR file.
103+
The arguments passed to `native-image` are evaluated left-to-right.
104+
This also extends to arguments that get passed indirectly via `META-INF/native-image` based native image configuration.
105+
Suppose you have a JAR file that contains _native-image.properties_ with `Args = -H:Optimize=0`.
106+
Then by using the `-H:Optimize=2` option after `-cp <jar-file>` you can override the setting that comes from the JAR file.
117107

118108
### Specifying Default Options for Native Image
119-
If there is a need to pass some options for every image build unconditionally, for
120-
example, to always generate an image in verbose mode (`--verbose`), you can
121-
make use of the `NATIVE_IMAGE_CONFIG_FILE` environment variable.
122-
If it is set to a Java properties file, the Native Image builder will use the
123-
default setting defined in there on each invocation. Write a
124-
configuration file and export
125-
`NATIVE_IMAGE_CONFIG_FILE=$HOME/.native-image/default.properties` in
126-
`~/.bash_profile`. Every time `native-image` gets used, it will implicitly use
127-
the arguments specified as `NativeImageArgs`, plus the arguments specified on the
128-
command line. Here is an example of a configuration file, saved as
129-
`~/.native-image/default.properties`:
109+
If there is a need to pass some options for every image build unconditionally, for example, to always generate an image in verbose mode (`--verbose`), you can make use of the `NATIVE_IMAGE_CONFIG_FILE` environment variable.
110+
If it is set to a Java properties file, the Native Image builder will use the default setting defined in there on each invocation.
111+
Write a configuration file and export `NATIVE_IMAGE_CONFIG_FILE=$HOME/.native-image/default.properties` in `~/.bash_profile`.
112+
Every time `native-image` gets used, it will implicitly use the arguments specified as `NativeImageArgs`, plus the arguments specified on the command line.
113+
Here is an example of a configuration file, saved as `~/.native-image/default.properties`:
130114

131115
```
132116
NativeImageArgs = --configurations-path /home/user/custom-image-configs \
@@ -146,9 +130,9 @@ export NATIVE_IMAGE_USER_HOME= $HOME/.local/share/native-image
146130
The native image build runs on the Java HotSpot VM and uses the memory management of the underlying platform.
147131
The usual Java HotSpot command-line options for garbage collection apply to the native image builder.
148132

149-
During the native image build, the representation of a whole program is created to
150-
figure out which classes and methods will be used at run time. It is a
151-
computationally intensive process. The default values for memory usage at image build time are:
133+
During the native image build, the representation of a whole program is created to figure out which classes and methods will be used at run time.
134+
It is a computationally intensive process.
135+
The default values for memory usage at image build time are:
152136
```
153137
-Xss10M \
154138
-Xms1G \
@@ -164,21 +148,16 @@ Check other related options to the native image builder from the `native-image -
164148

165149
## Runtime vs Build-Time Initialization
166150

167-
Building your application into a native image allows you to decide which parts
168-
of your application should be run at image build time and which parts have to
169-
run at image run time.
151+
Building your application into a native image allows you to decide which parts of your application should be run at image build time and which parts have to run at image run time.
170152

171-
All class-initialization code (static initializers and static
172-
field initialization) of the application you build an image for is executed
173-
at image run time by default. Sometimes it is beneficial to allow class
174-
initialization code to get executed at image build time for faster startup (e.g.,
175-
if some static fields get initialized to run-time independent data). This can be
176-
controlled with the following `native-image` options:
153+
All class-initialization code (static initializers and static field initialization) of the application you build an image for is executed at image run time by default.
154+
Sometimes it is beneficial to allow class initialization code to get executed at image build time for faster startup (e.g., if some static fields get initialized to run-time independent data).
155+
This can be controlled with the following `native-image` options:
177156

178157
* `--initialize-at-build-time=<comma-separated list of packages and classes>`
179158
* `--initialize-at-run-time=<comma-separated list of packages and classes>`
180159

181-
In addition to that, arbitrary computations are allowed at build time that can be put into `ImageSingletons` that are
182-
accessible at image run time. For more information please have a look at [Native Image configuration examples](https://github.com/graalvm/graalvm-demos/tree/master/native-image-configure-examples).
160+
In addition to that, arbitrary computations are allowed at build time that can be put into `ImageSingletons` that are accessible at image run time.
161+
For more information please have a look at [Native Image configuration examples](https://github.com/graalvm/graalvm-demos/tree/master/native-image-configure-examples).
183162

184163
For more information, continue reading to the [Class Initialization in Native Image](ClassInitialization.md) guide.

docs/reference-manual/native-image/C-API.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permalink: /reference-manual/native-image/C-API/
66
---
77
# Native Image C API
88

9-
Native Image provides an API for the C language for initializing isolates and attaching threads for use with the entry point feature that is demonstrated [here](README.md#images-and-entry-points).
9+
Native Image provides an API for the C language for initializing isolates and attaching threads for use with the entry point feature that is demonstrated [here](README.md/#images-and-entry-points).
1010
The C API is available when Native Image is built as a shared library and its declarations are included in the header file that is generated during the build.
1111

1212
```c
@@ -79,6 +79,4 @@ int graal_detach_thread(graal_isolatethread_t* thread);
7979
*/
8080
int graal_tear_down_isolate(graal_isolatethread_t* thread);
8181
```
82-
In addition to the C level API, there is also a way to initialize an isolate
83-
from Java and thus use Java and Native Image to
84-
[implement native methods in Java](ImplementingNativeMethodsInJavaWithSVM.md).
82+
In addition to the C level API, there is also a way to initialize an isolate from Java and thus use Java and Native Image to [implement native methods in Java](ImplementingNativeMethodsInJavaWithSVM.md).

docs/reference-manual/native-image/ClassInitialization.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ Access to the static fields that were initialized at build time is transparent t
1919
Specifying class initialization policies can be complicated due to the following constraints that come from class initialization semantics:
2020

2121
* When a class is initialized, all super classes and super interfaces with default methods must also be initialized.
22-
Interfaces without default methods, however, are not initialized. To describe this, a short-term "relevant supertype" is used furhter, and a relevant subtype for subtypes of classes and interfaces with default methods.
22+
Interfaces without default methods, however, are not initialized.
23+
To describe this, a short-term "relevant supertype" is used furhter, and a relevant subtype for subtypes of classes and interfaces with default methods.
24+
2325
* Relevant supertypes of types initialized at build time must also be initialized at build time.
2426
* Relevant subtypes of types initialized at run time must also be initialized at run time.
2527
* No instances classes that are initialized at run time must be present in the image.
@@ -31,7 +33,8 @@ To enjoy the complete out-of-the-box experience of Native Image and still get th
3133
* [Explicitly Specifying Class Initialization](#explicitly-specifying-class-initialization)
3234

3335
To track which classes were initialized and why, one can use the flag `-H:+PrintClassInitialization`.
34-
This flag greatly helps to configure the image build to work as intended. The goal is to have as many classes as possible initialized at build time, yet keep the correct semantics of the program.
36+
This flag greatly helps to configure the image build to work as intended.
37+
The goal is to have as many classes as possible initialized at build time, yet keep the correct semantics of the program.
3538

3639
## Build-Time Initialization of Native Image Runtime
3740

docs/reference-manual/native-image/DynamicProxy.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ Dynamic proxy classes are generated from a list of interfaces.
1212
Native Image does not provide machinery for generating and interpreting bytecodes at run time.
1313
Therefore all dynamic proxy classes need to be generated at native image build time.
1414

15-
See also the [guide on assisted configuration of Java resources and other dynamic features](BuildConfiguration.md#assisted-configuration-of-native-image-builds).
15+
See also the [guide on assisted configuration of Java resources and other dynamic features](BuildConfiguration.md/#assisted-configuration-of-native-image-builds).
1616

1717
## Automatic Detection
1818

19-
Native Image employs a simple static analysis that detects calls to `java.lang.reflect.Proxy.newProxyInstance(ClassLoader, Class<?>[], InvocationHandler)` and `java.lang.reflect.Proxy.getProxyClass(ClassLoader, Class<?>[])`, then tries to determine the list of interfaces that define dynamic proxies automatically. Given the list of interfaces, Native Image generates proxy classes at image build time and adds them to the native image heap.
19+
Native Image employs a simple static analysis that detects calls to `java.lang.reflect.Proxy.newProxyInstance(ClassLoader, Class<?>[], InvocationHandler)` and `java.lang.reflect.Proxy.getProxyClass(ClassLoader, Class<?>[])`, then tries to determine the list of interfaces that define dynamic proxies automatically.
20+
Given the list of interfaces, Native Image generates proxy classes at image build time and adds them to the native image heap.
2021
In addition to generating the dynamic proxy class, the constructor of the generated class that takes a `java.lang.reflect.InvocationHandler` argument, i.e., the one reflectively invoked by `java.lang.reflect.Proxy.newProxyInstance(ClassLoader, Class<?>[], InvocationHandler)`, is registered for reflection so that dynamic proxy instances can be allocated at run time.
2122

2223
The analysis is limited to situations where the list of interfaces comes from a constant array or an array that is allocated in the same method.

docs/reference-manual/native-image/HostedvsRuntimeOptions.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ permalink: /reference-manual/native-image/HostedvsRuntimeOptions/
66
---
77
# Native Image Hosted and Runtime Options
88

9-
Along with all the options listed in the [Options](Options.md)
10-
guide, Native Image also distinguishes hosted and runtime options.
9+
Along with all the options listed in the [Options](Options.md) guide, Native Image also distinguishes hosted and runtime options.
1110

1211
* Hosted options: configure a native image build, i.e., influence what is put into the image and how the image is built.
1312
These are set using the prefix `-H:` on the command line.
@@ -19,15 +18,11 @@ For developer documentation on how to define and use options, read the documenta
1918
## List of Useful Options
2019

2120
### Graph Dumping
22-
Native Image re-used the GraalVM options for graph dumping, logging, counters,
23-
and everything else in the GraalVM debug environment. These GraalVM options can
24-
be used both as hosted options (if you want to dump graphs of the native image
25-
builder), and as runtime options (if you want to dump graphs during dynamic
21+
Native Image re-used the GraalVM options for graph dumping, logging, counters, and everything else in the GraalVM debug environment.
22+
These GraalVM options can be used both as hosted options (if you want to dump graphs of the native image builder), and as runtime options (if you want to dump graphs during dynamic
2623
compilation at runtime).
2724

28-
The GraalVM compiler options that work as expected include `Dump`, `DumpOnError`, `Log`,
29-
`MethodFilter`, and the options to specify file names and ports for the dump
30-
handlers.
25+
The GraalVM compiler options that work as expected include `Dump`, `DumpOnError`, `Log`, `MethodFilter`, and the options to specify file names and ports for the dump handlers.
3126

3227
For example:
3328
* To dump the compiler graphs of the native image builder: `-H:Dump= -H:MethodFilter=ClassName.MethodName`.

0 commit comments

Comments
 (0)