Skip to content

Commit f825755

Browse files
authored
Added GraalVM for JDK 21 (#78)
Added Oracle GraalVM for JDK 21
1 parent 2f43027 commit f825755

File tree

4 files changed

+138
-56
lines changed

4 files changed

+138
-56
lines changed

oci-build-examples/oci_devops_build_with_graalenterprise/README.md

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Allow dynamic-group <YOUR_DynamicGroup_NAME> to use ons-topics in compartment <
7777
![](images/oci_buildpipeline_managedbuild.png)
7878

7979
- Click `Next` and provide the details.
80-
- In the `Build spec file path`, enter `build_spec.yaml` to use the [GraalVM Enterprise 22.x Java 17 build spec](build_spec.yaml). Alternatively, you can enter `build_spec_oracle_graalvm_jdk17.yaml` to use the [Oracle GraalVM for JDK 17 build spec](./build_spec_oracle_graalvm_jdk17.yaml) or `build_spec_oracle_graalvm_jdk20.yaml` to use the [Oracle GraalVM for JDK 20 build spec](./build_spec_oracle_graalvm_jdk20.yaml).
80+
- In the `Build spec file path`, enter `build_spec_oracle_graalvm_jdk21.yaml` to use [Oracle GraalVM for JDK 21](./build_spec_oracle_graalvm_jdk21.yaml) or `build_spec_oracle_graalvm_jdk17.yaml` to use [Oracle GraalVM for JDK 17](./build_spec_oracle_graalvm_jdk17.yaml). Alternatively, you can enter `build_spec.yaml` to use the legacy [GraalVM Enterprise 22.x Java 17](build_spec.yaml).
8181

8282
![](images/oci_buildstage_1.png)
8383

@@ -99,17 +99,17 @@ To install and use Oracle GraalVM in the DevOps build pipeline, the build specif
9999
```shell
100100
steps:
101101
- type: Command
102-
name: "Install Oracle GraalVM Enterprise 22.x Native Image for Java17"
102+
name: "Install Oracle GraalVM for JDK 21 (Native Image and JDK)"
103103
command: |
104-
yum -y install graalvm22-ee-17-native-image
104+
yum -y install graalvm-21-native-image
105105
```
106106

107107
2. Set the JAVA_HOME environment variable.
108108

109109
```shell
110110
env:
111111
variables:
112-
"JAVA_HOME" : "/usr/lib64/graalvm/graalvm22-ee-java17"
112+
"JAVA_HOME" : "/usr/lib64/graalvm/graalvm-java21"
113113
```
114114

115115
3. Set the PATH environment variable.
@@ -139,15 +139,13 @@ To install and use Oracle GraalVM in the DevOps build pipeline, the build specif
139139

140140
5. The executable file can be found under `target/my-app`.
141141

142-
```markdown
143-
- name: app_native_executable
144-
type: BINARY
145-
location: target/my-app
146-
```
142+
```markdown
143+
- name: app_native_executable
144+
type: BINARY
145+
location: target/my-app
146+
```
147147

148-
Here's the complete [build specification for GraalVM Enterprise 22.x Java 17](build_spec.yaml) file. Alternatively, you can use the
149-
[build specification for Oracle GraalVM for JDK 17](./build_spec_oracle_graalvm_jdk17.yaml) or
150-
[build specification for Oracle GraalVM for JDK 20](./build_spec_oracle_graalvm_jdk20.yaml).
148+
Here's the complete [build specification for Oracle GraalVM for JDK 21](./build_spec_oracle_graalvm_jdk21.yaml). Alternatively, you can use the [build specification for Oracle GraalVM for JDK 17](./build_spec_oracle_graalvm_jdk17.yaml) or the legacy [build specification for GraalVM Enterprise 22.x Java 17](build_spec.yaml) file.
151149
152150
153151
## How to export the executable file outside of the build pipeline stage.
@@ -171,7 +169,7 @@ The following instructions will help you to export the `executable app file` to
171169
172170
- Use option `Set Custom Location` as Artifact location.
173171
- Provide a path and version as `${BUILDRUN_HASH}`, this is to maintain immutable artifacts.
174-
- The variable `BUILDRUN_HASH` is derived during managed build stage and exported as an exportedVariables.You may use any other name ,but ensure to update the file [build_spec.yaml](build_spec.yaml).
172+
- The variable `BUILDRUN_HASH` is derived during managed build stage and exported as an exportedVariables.You may use any other name, but ensure to update the corresponding build specification file.
175173
- Select `Yes, substitute placeholders` as an option and click `Add`.
176174
177175
![](images/oci_devops_artifact_3.png)
@@ -186,7 +184,7 @@ The following instructions will help you to export the `executable app file` to
186184
187185
188186
- Use `app_native_executable` result artifact name.
189-
- The name `app_native_executable` is a reference to the outputArtifact defined under the the file [build_spec.yaml](build_spec.yaml).
187+
- The name `app_native_executable` is a reference to the outputArtifact defined under the corresponding build specification file.
190188
- Click `Add` and add the stage.
191189
192190
![](images/oci_upload_artifact.png)
@@ -217,7 +215,7 @@ The following instructions will help you to export the `executable app file` to
217215
## Optional - Run build with more verbose output.
218216

219217
- An additional build instruction file as [build_spec_verbose.yaml](build_spec_verbose.yaml)
220-
can be used for more verbose output with the managed build.
218+
can be used for more verbose output with the managed build.
221219
- To do so, switch to `OCI DevOps project` > `OCI Build pipeline ` > Click `3 dots` on the `Managed Build` stage and click on `View details` and then `Edit Stage`.
222220

223221
![](images/oci_buildstage_details.png)
@@ -235,54 +233,94 @@ The following instructions will help you to export the `executable app file` to
235233
```shell
236234
...
237235
EXEC: Installed:
238-
EXEC: graalvm22-ee-17-native-image.x86_64 0:22.1.0.1-1.el7
236+
EXEC: graalvm-21-native-image.x86_64 0:21.0.7-1.el7
239237
EXEC:
240238
EXEC: Dependency Installed:
241-
EXEC: glibc-static.x86_64 0:2.17-326.0.1.el7_9
242-
EXEC: graalvm22-ee-17-jdk.x86_64 0:22.1.0.1-1.el7
239+
EXEC: glibc-static.x86_64 0:2.17-326.0.9.el7_9.3
240+
EXEC: graalvm-21-jdk.x86_64 0:21.0.7-1.el7
243241
EXEC: libstdc++-static.x86_64 0:4.8.5-44.0.3.el7
244-
EXEC: zlib-static.x86_64 0:1.2.7-20.el7_9
242+
EXEC: zlib-static.x86_64 0:1.2.7-21.el7_9
245243
EXEC:
246-
EXEC: Complete!
244+
EXEC: Dependency Updated:
245+
EXEC: glibc.x86_64 0:2.17-326.0.9.el7_9.3
246+
EXEC: glibc-common.x86_64 0:2.17-326.0.9.el7_9.3
247+
EXEC: glibc-devel.x86_64 0:2.17-326.0.9.el7_9.3
248+
EXEC: glibc-headers.x86_64 0:2.17-326.0.9.el7_9.3
249+
EXEC:
250+
EXEC: Complete!
247251
...
248252
```
249253

250254
2. The native executable build log statements should be similar to:
251255

252256
```shell
253257
...
254-
EXEC: ==================================================================
258+
EXEC: ========================================================================================================================
255259
EXEC: GraalVM Native Image: Generating 'my-app' (executable)...
256-
EXEC: ==================================================================
257-
EXEC: [1/7] Initializing... (5.6s @ 0.11GB)
258-
EXEC: Version info: 'GraalVM 22.1.0.1 Java 17 EE'
260+
EXEC: ========================================================================================================================
261+
EXEC: For detailed information and explanations on the build output, visit:
262+
EXEC: https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
263+
EXEC: ------------------------------------------------------------------------------------------------------------------------
264+
EXEC: [1/8] Initializing... (3.6s @ 0.09GB)
265+
EXEC: Java version: 21.0.7+8-LTS, vendor version: Oracle GraalVM 21.0.7+8.1
266+
EXEC: Graal compiler: optimization level: 2, target machine: x86-64-v3, PGO: ML-inferred
259267
EXEC: C compiler: gcc (redhat, x86_64, 4.8.5)
260-
EXEC: Garbage collector: Serial GC
261-
EXEC: [2/7] Performing analysis... [******] (9.5s @ 0.32GB)
262-
EXEC: 1,880 (62.46%) of 3,010 classes reachable
263-
EXEC: 1,684 (46.71%) of 3,605 fields reachable
264-
EXEC: 7,784 (36.98%) of 21,049 methods reachable
265-
EXEC: 21 classes, 0 fields, and 285 methods registered for reflection
266-
EXEC: 48 classes, 32 fields, and 47 methods registered for JNI access
267-
EXEC: [3/7] Building universe... (1.1s @ 0.45GB)
268-
EXEC: [4/7] Parsing methods... [*] (0.8s @ 0.58GB)
269-
EXEC: [5/7] Inlining methods... [****] (1.2s @ 0.97GB)
270-
EXEC: [6/7] Compiling methods... [*****] (21.2s @ 0.75GB)
271-
EXEC: [7/7] Creating image... (0.9s @ 0.92GB)
272-
EXEC: 2.62MB (46.31%) for code area: 3,708 compilation units
273-
EXEC: 2.45MB (43.34%) for image heap: 945 classes and 38,518 objects
274-
EXEC: 600.06KB (10.35%) for other data
275-
EXEC: 5.66MB in total
276-
EXEC: ------------------------------------------------------------------
277-
...
278-
EXEC: ------------------------------------------------------------------
279-
EXEC: 0.9s (2.1% of total time) in 18 GCs | Peak RSS: 2.44GB | CPU load: 3.41
280-
EXEC: ------------------------------------------------------------------
268+
EXEC: Garbage collector: Serial GC (max heap size: 80% of RAM)
269+
EXEC: 1 user-specific feature(s):
270+
EXEC: - com.oracle.svm.thirdparty.gson.GsonFeature
271+
EXEC: ------------------------------------------------------------------------------------------------------------------------
272+
EXEC: Build resources:
273+
EXEC: - 5.11GB of memory (75.6% of 6.76GB system memory, determined at start)
274+
EXEC: - 4 thread(s) (100.0% of 4 available processor(s), determined at start)
275+
EXEC: [2/8] Performing analysis... [*****] (8.5s @ 0.19GB)
276+
EXEC: 2,052 reachable types (60.0% of 3,421 total)
277+
EXEC: 1,935 reachable fields (45.3% of 4,272 total)
278+
EXEC: 8,767 reachable methods (36.2% of 24,223 total)
279+
EXEC: 741 types, 37 fields, and 332 methods registered for reflection
280+
EXEC: 49 types, 33 fields, and 48 methods registered for JNI access
281+
EXEC: 4 native libraries: dl, pthread, rt, z
282+
EXEC: [3/8] Building universe... (1.5s @ 0.23GB)
283+
EXEC: [4/8] Parsing methods... [**] (2.7s @ 0.23GB)
284+
EXEC: [5/8] Inlining methods... [***] (0.8s @ 0.24GB)
285+
EXEC: [6/8] Compiling methods... [****] (17.1s @ 0.27GB)
286+
EXEC: [7/8] Laying out methods... [*] (0.7s @ 0.26GB)
287+
EXEC: [8/8] Creating image... [*] (1.1s @ 0.23GB)
288+
EXEC: 2.82MB (42.58%) for code area: 3,945 compilation units
289+
EXEC: 3.18MB (48.04%) for image heap: 53,077 objects and 43 resources
290+
EXEC: 636.31kB ( 9.39%) for other data
291+
EXEC: 6.62MB in total
292+
EXEC: ------------------------------------------------------------------------------------------------------------------------
293+
EXEC: Top 10 origins of code area: Top 10 object types in image heap:
294+
EXEC: 1.41MB java.base 765.27kB byte[] for code metadata
295+
EXEC: 1.12MB svm.jar (Native Image) 693.88kB byte[] for java.lang.String
296+
EXEC: 84.35kB com.oracle.svm.svm_enterprise 363.73kB java.lang.String
297+
EXEC: 42.24kB jdk.proxy2 322.13kB java.lang.Class
298+
EXEC: 37.79kB jdk.proxy1 168.13kB java.util.HashMap$Node
299+
EXEC: 30.20kB org.graalvm.nativeimage.base 114.01kB char[]
300+
EXEC: 27.42kB org.graalvm.collections 94.77kB heap alignment
301+
EXEC: 21.20kB jdk.internal.vm.ci 81.83kB java.lang.Object[]
302+
EXEC: 16.79kB jdk.internal.vm.compiler 81.45kB byte[] for reflection metadata
303+
EXEC: 11.80kB jdk.proxy3 80.16kB com.oracle.svm.core.hub.DynamicHubCompanion
304+
EXEC: 389.00B for 1 more packages 490.66kB for 523 more object types
305+
EXEC: Use '-H:+BuildReport' to create a report with more details.
306+
EXEC: ------------------------------------------------------------------------------------------------------------------------
307+
EXEC: Security report:
308+
EXEC: - Binary does not include Java deserialization.
309+
EXEC: - Use '--enable-sbom' to embed a Software Bill of Materials (SBOM) in the binary.
310+
EXEC: ------------------------------------------------------------------------------------------------------------------------
311+
EXEC: Recommendations:
312+
EXEC: G1GC: Use the G1 GC ('--gc=G1') for improved latency and throughput.
313+
EXEC: PGO: Use Profile-Guided Optimizations ('--pgo') for improved throughput.
314+
EXEC: INIT: Adopt '--strict-image-heap' to prepare for the next GraalVM release.
315+
EXEC: HEAP: Set max heap for improved and more predictable memory usage.
316+
EXEC: CPU: Enable more CPU features with '-march=native' for improved performance.
317+
EXEC: ------------------------------------------------------------------------------------------------------------------------
318+
EXEC: 2.8s (7.5% of total time) in 262 GCs | Peak RSS: 0.79GB | CPU load: 3.27
319+
EXEC: ------------------------------------------------------------------------------------------------------------------------
281320
EXEC: Produced artifacts:
282321
EXEC: /workspace/gvmee-yum/target/my-app (executable)
283-
EXEC: /workspace/gvmee-yum/target/my-app.build_artifacts.txt
284-
EXEC: ==================================================================
285-
EXEC: Finished generating 'my-app' in 41.7s.
322+
EXEC: ========================================================================================================================
323+
EXEC: Finished generating 'my-app' in 36.7s.
286324
...
287325
```
288326

@@ -298,7 +336,7 @@ Contributors
298336

299337
- Author: [Rahul M R](https://github.com/RahulMR42).
300338
- Collaborators: [Sachin Pikle](https://github.com/sachin-pikle)
301-
- Last release: July 2022
339+
- Last updated: July 2025
302340

303341
### Back to examples.
304342
----
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: 0.1
2+
component: build
3+
timeoutInSeconds: 600
4+
runAs: root
5+
shell: bash
6+
env:
7+
exportedVariables:
8+
- BUILDRUN_HASH
9+
variables:
10+
"JAVA_HOME" : "/usr/lib64/graalvm/graalvm-java21"
11+
# PATH is a reserved variable and cannot be defined as a variable.
12+
# However, PATH can be changed in a build step and the change is visible in subsequent steps.
13+
steps:
14+
- type: Command
15+
name: "Define unique tag"
16+
timeoutInSeconds: 40
17+
command: |
18+
export BUILDRUN_HASH=`echo ${OCI_BUILD_RUN_ID} | rev | cut -c 1-7`
19+
echo "BUILDRUN_HASH: " $BUILDRUN_HASH
20+
21+
- type: Command
22+
name: "Install Oracle GraalVM for JDK 21 (Native Image and JDK)"
23+
command: |
24+
yum -y install graalvm-21-native-image
25+
- type: Command
26+
name: "Set PATH Variable"
27+
command: |
28+
export PATH=$JAVA_HOME/bin:$PATH
29+
# - type: Command
30+
# name: "Build a Jar"
31+
# command: |
32+
# mvn --no-transfer-progress clean package
33+
- type: Command
34+
name: "Build a native executable "
35+
command: |
36+
mvn --no-transfer-progress -Pnative -DskipTests package
37+
38+
outputArtifacts:
39+
# - name: app_jar
40+
# type: BINARY
41+
# location: target/my-app-1.0-SNAPSHOT.jar
42+
- name: app_native_executable
43+
type: BINARY
44+
location: target/my-app

oci-build-examples/oci_devops_build_with_graalenterprise/build_spec_verbose.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
exportedVariables:
1111
- BUILDRUN_HASH
1212
variables:
13-
"JAVA_HOME" : "/usr/lib64/graalvm/graalvm22-ee-java17"
13+
"JAVA_HOME" : "/usr/lib64/graalvm/graalvm-java21"
1414
# PATH is a reserved variable and cannot be defined as a variable.
1515
# However, PATH can be changed in a build step and the change is visible in subsequent steps.
1616
steps:
@@ -24,15 +24,15 @@ steps:
2424
- type: Command
2525
name: "Pre-yum repo checks"
2626
command: |
27-
printf "\n\n Contents of graal_spec.yaml file:\n $(cat graal_spec.yaml) \n\n"
27+
printf "\n\n Contents of build_spec_verbose.yaml file:\n $(cat build_spec_verbose.yaml) \n\n"
2828
printf "Contents of /etc/pki/rpm-gpg/:\n $(ls -alh /etc/pki/rpm-gpg/) \n"
2929
printf "Contents of /etc/yum.repos.d/:\n $(ls -alh /etc/yum.repos.d/) \n"
3030
printf "Contents of etc/yum.repos.d/oci-included-ol7.repo file:\n $(cat "etc/yum.repos.d/oci-included-ol7.repo") \n"
31-
printf "Output of yum list graalvm22-ee-17* :\n $(yum list graalvm22-ee-17*) \n"
31+
printf "Output of yum list graalvm-21* :\n $(yum list graalvm-21*) \n"
3232
- type: Command
33-
name: "Install GraalVM 22.x Native Image for Java17"
33+
name: "Install Oracle GraalVM for JDK 21 (Native Image and JDK)"
3434
command: |
35-
yum -y install graalvm22-ee-17-native-image
35+
yum -y install graalvm-21-native-image
3636
- type: Command
3737
name: "Set PATH Variable"
3838
command: |
@@ -49,7 +49,7 @@ steps:
4949
printf "Maven version:\n $(mvn --version) \n"
5050
echo "Current dir: $(pwd)"
5151
printf "Current dir contents:\n $(ls -alh)"
52-
printf "Output of yum list graalvm22-ee-17* :\n $(yum list graalvm22-ee-17*) \n"
52+
printf "Output of yum list graalvm-21* :\n $(yum list graalvm-21*) \n"
5353
- type: Command
5454
name: "Build a Jar"
5555
command: |

oci-build-examples/oci_devops_build_with_graalenterprise/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<maven.compiler.source>17</maven.compiler.source>
1818
<maven.compiler.target>17</maven.compiler.target>
1919
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
20-
<native.maven.plugin.version>0.9.13</native.maven.plugin.version>
20+
<native.maven.plugin.version>0.10.6</native.maven.plugin.version>
2121
</properties>
2222

2323
<dependencies>

0 commit comments

Comments
 (0)