Skip to content

Commit e7482bf

Browse files
authored
Merge pull request #50683 from zakkak/2025-10-23-fix-49905-in-native
Disable warnings about unsafe usage of Unsafe in native
2 parents 365da76 + a78e3b4 commit e7482bf

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import io.quarkus.maven.dependency.ResolvedDependency;
5555
import io.quarkus.runtime.LocalesBuildTimeConfig;
5656
import io.quarkus.runtime.graal.DisableLoggingFeature;
57+
import io.quarkus.runtime.graal.JVMChecksFeature;
5758
import io.quarkus.sbom.ApplicationComponent;
5859
import io.quarkus.sbom.ApplicationManifestConfig;
5960
import io.smallrye.common.cpu.CPU;
@@ -88,6 +89,7 @@ public class NativeImageBuildStep {
8889
void nativeImageFeatures(BuildProducer<NativeImageFeatureBuildItem> features) {
8990
features.produce(new NativeImageFeatureBuildItem(NativeImageFeatureStep.GRAAL_FEATURE));
9091
features.produce(new NativeImageFeatureBuildItem(DisableLoggingFeature.class));
92+
features.produce(new NativeImageFeatureBuildItem(JVMChecksFeature.class));
9193
}
9294

9395
@BuildStep(onlyIf = NativeBuild.class)

core/runtime/src/main/java/io/quarkus/runtime/JVMChecksRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class JVMChecksRecorder {
1313
* we know about the problem, we're working on it, and there's no need to print a warning scaring our
1414
* users with it.
1515
*/
16-
public void disableUnsafeRelatedWarnings() {
16+
public static void disableUnsafeRelatedWarnings() {
1717
if (Runtime.version().feature() < 24) {
1818
return;
1919
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.quarkus.runtime.graal;
2+
3+
import org.graalvm.nativeimage.hosted.Feature;
4+
5+
import io.quarkus.runtime.JVMChecksRecorder;
6+
7+
/**
8+
* This is a horrible hack to disable the Unsafe-related warnings that are printed on startup:
9+
* we know about the problem, we're working on it, and there's no need to print a warning scaring our
10+
* users with it.
11+
*/
12+
public class JVMChecksFeature implements Feature {
13+
14+
@Override
15+
public void duringSetup(Feature.DuringSetupAccess access) {
16+
JVMChecksRecorder.disableUnsafeRelatedWarnings();
17+
}
18+
19+
}

0 commit comments

Comments
 (0)