From 59939ce3e992bca582706e3b4156a186e2738f69 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Wed, 13 Sep 2023 09:13:59 +0300 Subject: [PATCH] Adopt --strict-image-heap that will land in GraalVM for JDK 21 oracle/graal#7393 adds a new --strict-image-heap option, that will eventually become the new default. Quarkus should start using the option with GraalVM for JDK 21 (23.1.0) to be able to test it before it becomes the new default. Closes #35901 --- .../quarkus/deployment/pkg/steps/NativeImageBuildStep.java | 5 +++++ .../io/quarkus/deployment/steps/NativeImageFeatureStep.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java index f52639b29d09d..a180c416e09c4 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java @@ -796,6 +796,11 @@ public NativeImageInvokerInfo build() { "-H:BuildOutputJSONFile=" + nativeImageName + "-build-output-stats.json"); } + // only available in GraalVM 23.1.0+. Expected to become the default in GraalVM 24.0.0. + if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_1_0) >= 0) { + nativeImageArgs.add("--strict-image-heap"); + } + /* * Any parameters following this call are forced over the user provided parameters in * quarkus.native.additional-build-args. So if you need a parameter to be overridable through diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java index bf8db1fa84953..d2284c56d422f 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java @@ -49,7 +49,7 @@ public class NativeImageFeatureStep { @BuildStep void addExportsToNativeImage(BuildProducer features) { // required in order to access org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport - // prior to 23.1 the class was provided by org.graalvm.sdk module and with 23.1 onwards, it's provided by org.graalvm.nativimage instead + // prior to 23.1 the class was provided by org.graalvm.sdk module and with 23.1 onwards, it's provided by org.graalvm.nativeimage instead features.produce(new JPMSExportBuildItem("org.graalvm.sdk", "org.graalvm.nativeimage.impl", null, GraalVM.Version.VERSION_23_1_0)); features.produce(new JPMSExportBuildItem("org.graalvm.nativeimage", "org.graalvm.nativeimage.impl",