diff --git a/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java b/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java index 091b30845029a..df7c1571466b4 100644 --- a/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java +++ b/extensions/awt/deployment/src/main/java/io/quarkus/awt/deployment/AwtProcessor.java @@ -2,7 +2,8 @@ import static io.quarkus.deployment.builditem.nativeimage.UnsupportedOSBuildItem.Os.WINDOWS; -import io.quarkus.awt.runtime.graal.AwtFeature; +import java.util.stream.Stream; + import io.quarkus.awt.runtime.graal.DarwinAwtFeature; import io.quarkus.deployment.Feature; import io.quarkus.deployment.annotations.BuildProducer; @@ -13,6 +14,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeMinimalJavaVersionBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedPackageBuildItem; import io.quarkus.deployment.builditem.nativeimage.UnsupportedOSBuildItem; import io.quarkus.deployment.pkg.steps.NativeBuild; import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; @@ -26,7 +28,6 @@ FeatureBuildItem feature() { @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) void nativeImageFeatures(BuildProducer nativeImageFeatures) { - nativeImageFeatures.produce(new NativeImageFeatureBuildItem(AwtFeature.class)); nativeImageFeatures.produce(new NativeImageFeatureBuildItem(DarwinAwtFeature.class)); } @@ -197,4 +198,21 @@ JniRuntimeAccessBuildItem setupJava2DClasses() { "sun.java2d.SunGraphics2D", "sun.java2d.SurfaceData"); } + + @BuildStep + void runtimeInitializedClasses(BuildProducer runtimeInitilizedPackages) { + /* + * Note that this initialization is not enough if user wants to deserialize actual images + * (e.g. from XML). AWT Extension must be loaded for decoding JDK supported image formats. + */ + Stream.of("com.sun.imageio", + "java.awt", + "javax.imageio", + "sun.awt", + "sun.font", + "sun.java2d") + .map(RuntimeInitializedPackageBuildItem::new) + .forEach(runtimeInitilizedPackages::produce); + } + } diff --git a/extensions/awt/runtime/src/main/java/io/quarkus/awt/runtime/graal/AwtFeature.java b/extensions/awt/runtime/src/main/java/io/quarkus/awt/runtime/graal/AwtFeature.java deleted file mode 100644 index 34b8606751dca..0000000000000 --- a/extensions/awt/runtime/src/main/java/io/quarkus/awt/runtime/graal/AwtFeature.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.quarkus.awt.runtime.graal; - -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; - -/** - * Note that this initialization is not enough if user wants to deserialize actual images - * (e.g. from XML). AWT Extension must be loaded for decoding JDK supported image formats. - */ -public class AwtFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - // Quarkus run time init for AWT - RuntimeClassInitialization.initializeAtRunTime( - "com.sun.imageio", - "java.awt", - "javax.imageio", - "sun.awt", - "sun.font", - "sun.java2d"); - } -}