Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
name: native-image-configure-examples
name: archive/class-initialization-examples
on:
push:
paths:
- 'native-image-configure-examples/**'
- '.github/workflows/native-image-configure-examples.yml'
- 'archive/class-initialization-examples/**'
- '.github/workflows/archive-class-initialization-examples.yml'
pull_request:
paths:
- 'native-image-configure-examples/**'
- '.github/workflows/native-image-configure-examples.yml'
schedule:
- cron: "0 0 1 * *" # run every month
- 'archive/class-initialization-examples/**'
- '.github/workflows/archive-class-initialization-examples.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
run:
name: Run 'native-image-configure-examples'
name: Run 'archive/class-initialization-examples'
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
java-version: ['21', 'latest-ea']
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: ${{ matrix.java-version }}
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- name: Run 'configure-at-runtime-example'
run: |
cd native-image-configure-examples/configure-at-runtime-example
cd archive/class-initialization-examples/configure-at-runtime-example
mvn --no-transfer-progress package
./target/runtime-example
- name: Run 'configure-at-buildtime-example'
run: |
cd native-image-configure-examples/configure-at-buildtime-example
cd archive/class-initialization-examples/configure-at-buildtime-example
mvn --no-transfer-progress package
./target/buildtime-example
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ cd graalvm-demos
<td align="left" width="70%">Demonstrates how the Graal compiler can achieve better performance for highly abstracted programs like those using Streams, Lambdas<br><strong>Technologies: </strong>Graal compiler, C2<br><strong>Reference: </strong><a href="https://luna.oracle.com/lab/d502417b-df66-45be-9fed-a3ac8e3f09b1/steps#task-2-run-demos-java-microbenchmark-harness-jmh">Simple Java Stream Benchmark</a></td>
</tr>
<tr>
<td align="left" width="30%"><a href="/native-image-configure-examples/">native-image-configure-examples</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml"><img alt="streams" src="https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml/badge.svg" /></a></td>
<td align="left" width="70%">Demonstrates how you can influence the classes initialization at the image build time<br><strong>Technologies: </strong>Native Image, Maven<br><strong>Reference: </strong><a href="https://medium.com/graalvm/understanding-class-initialization-in-graalvm-native-image-generation-d765b7e4d6ed">Understanding Class Initialization in GraalVM Native Image Generation</a></td>
<td align="left" width="30%"><a href="/multithreading-demo/">multithreading-demo</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml"><img alt="streams" src="https://github.com/graalvm/graalvm-demos/actions/workflows/streams.yml/badge.svg" /></a></td>
<td align="left" width="70%">Demonstrates how to optimize a Java application that does synchronous and asynchronous threads execution<br><strong>Technologies: </strong>Native Image Build Reports, Native Build Tools Maven plugin <br><strong>Reference: </strong><a href="https://medium.com/graalvm/making-sense-of-native-image-contents-741a688dab4d">Making sense of Native Image contents</a></td>
</tr>
<tr>
<td align="left" width="30%"><a href="/native-netty-plot/">native-netty-plot</a><br><a href="https://github.com/graalvm/graalvm-demos/actions/workflows/native-netty-plot.yml"><img alt="native-netty-plot" src="https://github.com/graalvm/graalvm-demos/actions/workflows/native-netty-plot.yml/badge.svg" /></a></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ In both examples we use the Jackson framework to parse a JSON file to determine

1. Download and install the latest GraalVM JDK using [SDKMAN!](https://sdkman.io/).
```bash
sdk install java 21.0.1-graal
sdk install java 21.0.5-graal
```

2. Download or clone the repository and navigate into the `native-image-configure-examples` directory:
2. Download or clone the repository and navigate into the `class-initialization-examples` directory:
```bash
git clone https://github.com/graalvm/graalvm-demos
```
```bash
cd graalvm-demos/native-image-configure-examples
cd graalvm-demos/archive/class-initialization-examples
```

## Build and Run Examples

1. Change to one of the demo subdirectories, for example, `configure-at-runtime-example`:
```bash
cd graalvm-demos/native-image-configure-examples/configure-at-runtime-example
cd configure-at-runtime-example
```
2. Build the project:
```bash
mvn package
```
3. Once the Maven build succeeds, a native executable called "runtime-example" will be generated in the `configure-at-runtime-example/target/` directory. Run it:
3. Once the Maven build succeeds, a native executable called "runtime-example" will be generated in the _configure-at-runtime-example/target/_ directory. Run it:
```bash
./target/runtime-example
```
Expand All @@ -63,7 +63,4 @@ In both examples we use the Jackson framework to parse a JSON file to determine

Loading application configuration at executable build time can speed up application startup.

### Related Documentation

- [Build-Time Initialization](https://www.graalvm.org/latest/reference-manual/native-image/optimizations-and-performance/ClassInitialization/)
- [Initialize Once, Start Fast: Application Initialization at Build Time](http://www.christianwimmer.at/Publications/Wimmer19a/Wimmer19a.pdf)
Learn more about [Class Initialization in Native Image](https://www.graalvm.org/latest/reference-manual/native-image/optimizations-and-performance/ClassInitialization/) at the website, and from the blog post [Understanding Class Initialization in GraalVM Native Image Generation](https://medium.com/graalvm/understanding-class-initialization-in-graalvm-native-image-generation-d765b7e4d6ed).
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<native.maven.plugin.version>0.10.2</native.maven.plugin.version>
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
<jackson.version>2.16.0</jackson.version>
</properties>

Expand Down Expand Up @@ -83,9 +83,6 @@
<configuration>
<skip>false</skip>
<imageName>buildtime-example</imageName>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<native.maven.plugin.version>0.10.2</native.maven.plugin.version>
<native.maven.plugin.version>0.10.4</native.maven.plugin.version>
<jackson.version>2.16.0</jackson.version>
</properties>

Expand Down Expand Up @@ -83,9 +83,6 @@
</executions>
<configuration>
<imageName>runtime-example</imageName>
<buildArgs>
--no-fallback
</buildArgs>
</configuration>
</plugin>
</plugins>
Expand Down
Loading