Skip to content

Commit bbdb6e2

Browse files
committed
Review and move native-netty-plot to archive
1 parent bcf2be7 commit bbdb6e2

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed
File renamed without changes.

native-netty-plot/README.md renamed to archive/native-netty-plot/README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Isolates for GraalVM Native Images
1+
# Use of Isolates with Native Image
22

33
This application demonstrates the use of _isolates_ with [GraalVM Native Image](https://www.graalvm.org/latest/reference-manual/native-image/).
44
The code implements a web service that renders plots of mathematical functions, such as _sin(x)_.
@@ -22,33 +22,34 @@ There is also the [Maven plugin for GraalVM Native Image building](https://graal
2222
git clone https://github.com/graalvm/graalvm-demos
2323
```
2424
```bash
25-
cd graalvm-demos/native-netty-plot
25+
cd graalvm-demos/archive/native-netty-plot
2626
```
27+
2728
For compilation, the `native-image` depends on the local toolchain.
28-
Please make sure that `glibc-devel`, `zlib-devel` (header files for the C library and zlib), and `gcc` are available on your system. Some Linux distributions may additionally require `libstdc++-static`.
29+
Make sure that `glibc-devel`, `zlib-devel` (header files for the C library and zlib), and `gcc` are available on your system. Some Linux distributions may additionally require `libstdc++-static`.
2930
See [Prerequisites for Native Image](https://www.graalvm.org/latest/reference-manual/native-image/#prerequisites).
3031

31-
## Build the Project
32+
## Build the Application
3233

3334
The example is built with Maven:
3435
```bash
3536
mvn package
3637
```
3738

38-
This creates a JAR file with all dependencies embedded: `target/netty-plot-0.1-jar-with-dependencies.jar`.
39+
This creates a JAR file with all dependencies embedded in the _target/_ directory.
3940

4041
## Generate a Native Executable
4142

4243
If the application is expected to use some dynamic features at run time (e.g., Reflection, Java Native Interface, class path resources), they have to be provided to the `native-image` tool in the form of configuration files.
4344
To avoid writing the configuration file yourself, apply the [tracing agent](https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/) when running on the Java HotSpot VM.
4445
It will observe the application behavior and create configuration files (_jni-config.json_, _reflect-config.json_, _proxy-config.json_ and _resource-config.json_) in the _META-INF/native-image_ directory on the class path.
45-
The _reflect-config.json_ file specifies classes which must be available via Java reflection at runtime.
46+
The _reflect-config.json_ file specifies classes which must be available via Java reflection at run time.
4647

47-
1. Run the application on GraalVM JDK applying the tracing agent:
48+
1. Run the application on the GraalVM JDK applying the tracing agent:
4849
```bash
4950
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar target/netty-plot-0.1-jar-with-dependencies.jar
5051
```
51-
The server is started. Open _http://127.0.0.1:8080/?useIsolate=false_ in the browser to see the output.
52+
The server is started. Open [http://127.0.0.1:8080/?useIsolate=false](http://127.0.0.1:8080/?useIsolate=false) in the browser to see the output.
5253

5354
2. Terminate the application, `CTRL+C`.
5455

@@ -66,25 +67,27 @@ The _reflect-config.json_ file specifies classes which must be available via Jav
6667
```bash
6768
./netty-plot
6869
```
69-
Open your web browser and navigate to http://127.0.0.1:8080/
70+
Open your web browser and navigate to [http://127.0.0.1:8080/](http://127.0.0.1:8080/)
7071

71-
5. Finally, you can open your browser and request rendering of a function, for example, by browsing to `http://127.0.0.1:8080/?function=abs((x-31.4)sin(x-pi/2))&xmin=0&xmax=31.4`.
72+
5. Finally, you can open your browser and request rendering of a function, for example, by browsing to [http://127.0.0.1:8080/?function=abs((x-31.4)sin(x-pi/2))&xmin=0&xmax=31.4](http://127.0.0.1:8080/?function=abs((x-31.4)sin(x-pi/2))&xmin=0&xmax=31.4).
7273

7374
### Background Information
7475

7576
Instead of specifying any additional parameters on the command line, they may provided in a properties file in the input JAR file.
76-
The `native-image` builder automatically looks for files named `native-image.properties` and for any other configuration file under `META-INF/native-image` including subdirectories, and processes their contents.
77+
The `native-image` builder automatically looks for files named _native-image.properties_ and for any other configuration file under _META-INF/native-image_ including subdirectories, and processes their contents.
7778
The tracing agent writes the _reflect-config.json_ file specifying classes which must be available via Java reflection at run time.
7879

79-
With Maven projects, the path convention is `META-INF/native-image/${groupId}/${artifactId}/native-image.properties`.
80-
In this example, the `META-INF/native-image/com.oracle.substratevm/netty-plot/native-image.properties` file contains the following:
80+
With Maven projects, the path convention is _META-INF/native-image/${groupId}/${artifactId}/native-image.properties_.
81+
In this example, the _META-INF/native-image/com.oracle.substratevm/netty-plot/native-image.properties_ file contains the following:
8182
```bash
8283
ImageName = netty-plot
8384
Args = --link-at-build-time
8485
```
8586
The `ImageName` property specifies the name of the resulting executable, while `Args` are treated like additional command-line arguments.
8687

87-
### A note about the application
88+
#### A note about the application
8889

89-
This example cannot run as a regular Java application (on the JVM) and it cannot be profiled.
90+
This example cannot run as a regular Java application (on HotSpot) and it cannot be profiled.
9091
It will fail because the program tries to create an [isolate which is a Native Image specific feature](https://medium.com/graalvm/isolates-and-compressed-references-more-flexible-and-efficient-memory-management-for-graalvm-a044cc50b67e).
92+
93+
Read more in the blog post [Instant Netty Startup using GraalVM Native Image Generation](https://medium.com/graalvm/instant-netty-startup-using-graalvm-native-image-generation-ed6f14ff7692).

native-netty-plot/pom.xml renamed to archive/native-netty-plot/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<properties>
1010
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1111
<java.version>21</java.version>
12-
<native.maven.plugin.version>0.9.28</native.maven.plugin.version>
12+
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
1313
<maven.compiler.source>${java.specification.version}</maven.compiler.source>
1414
<maven.compiler.target>${java.specification.version}</maven.compiler.target>
1515
</properties>
@@ -60,7 +60,7 @@
6060
<imageName>${imageName}</imageName>
6161
<fallback>false</fallback>
6262
<buildArgs>
63-
--no-fallback
63+
<buildArg>--no-fallback</buildArg>
6464
</buildArgs>
6565
<agent>
6666
<enabled>true</enabled>

native-netty-plot/src/main/resources/META-INF/native-image/com.oracle.substratevm/netty-plot/native-image.properties

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)