diff --git a/core/deployment/src/main/java/io/quarkus/deployment/Java2DProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/Java2DProcessor.java new file mode 100644 index 0000000000000..7b0b7be54fdf6 --- /dev/null +++ b/core/deployment/src/main/java/io/quarkus/deployment/Java2DProcessor.java @@ -0,0 +1,69 @@ +package io.quarkus.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.nativeimage.JniRuntimeAccessBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; + +public class Java2DProcessor { + + @BuildStep + ReflectiveClassBuildItem setupReflectionClasses() { + return new ReflectiveClassBuildItem(false, false, + "sun.awt.X11GraphicsEnvironment", + "sun.awt.X11.XToolkit"); + } + + @BuildStep + JniRuntimeAccessBuildItem setupJava2DClasses() { + return new JniRuntimeAccessBuildItem(true, true, true, + "java.awt.AlphaComposite", + "java.awt.Color", + "java.awt.geom.AffineTransform", + "java.awt.geom.Path2D", + "java.awt.geom.Path2D$Float", + "java.awt.image.BufferedImage", + "java.awt.image.ColorModel", + "java.awt.image.IndexColorModel", + "java.awt.image.Raster", + "java.awt.image.SampleModel", + "java.awt.image.SinglePixelPackedSampleModel", + "sun.awt.SunHints", + "sun.awt.image.BufImgSurfaceData$ICMColorData", + "sun.awt.image.ByteComponentRaster", + "sun.awt.image.BytePackedRaster", + "sun.awt.image.ImageRepresentation", + "sun.awt.image.IntegerComponentRaster", + "sun.java2d.Disposer", + "sun.java2d.InvalidPipeException", + "sun.java2d.NullSurfaceData", + "sun.java2d.SunGraphics2D", + "sun.java2d.SurfaceData", + "sun.java2d.loops.Blit", + "sun.java2d.loops.BlitBg", + "sun.java2d.loops.CompositeType", + "sun.java2d.loops.DrawGlyphList", + "sun.java2d.loops.DrawGlyphListAA", + "sun.java2d.loops.DrawGlyphListLCD", + "sun.java2d.loops.DrawLine", + "sun.java2d.loops.DrawParallelogram", + "sun.java2d.loops.DrawPath", + "sun.java2d.loops.DrawPolygons", + "sun.java2d.loops.DrawRect", + "sun.java2d.loops.FillParallelogram", + "sun.java2d.loops.FillPath", + "sun.java2d.loops.FillRect", + "sun.java2d.loops.FillSpans", + "sun.java2d.loops.GraphicsPrimitive", + "sun.java2d.loops.GraphicsPrimitiveMgr", + "sun.java2d.loops.GraphicsPrimitive[]", + "sun.java2d.loops.MaskBlit", + "sun.java2d.loops.MaskFill", + "sun.java2d.loops.ScaledBlit", + "sun.java2d.loops.SurfaceType", + "sun.java2d.loops.TransformHelper", + "sun.java2d.loops.XORComposite", + "sun.java2d.pipe.Region", + "sun.java2d.pipe.RegionIterator"); + } + +} 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 75ba060b0e62c..99bda7864b5a1 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 @@ -602,6 +602,8 @@ public NativeImageInvokerInfo build() { } handleAdditionalProperties(nativeConfig, nativeImageArgs, isContainerBuild, outputDir); + nativeImageArgs + .add("--initialize-at-run-time=java.awt,javax.imageio,sun.awt,sun.java2d,sun.font,com.sun.imageio,org.apache.pdfbox,org.apache.poi.hssf.util,org.apache.poi.ss.format"); nativeImageArgs.add( "-H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime"); //the default collection policy results in full GC's 50% of the time nativeImageArgs.add("-H:+JNI"); diff --git a/core/runtime/src/main/java/io/quarkus/runtime/graal/Java2DSubstitutions.java b/core/runtime/src/main/java/io/quarkus/runtime/graal/Java2DSubstitutions.java deleted file mode 100644 index 0ca2b30ab278e..0000000000000 --- a/core/runtime/src/main/java/io/quarkus/runtime/graal/Java2DSubstitutions.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.quarkus.runtime.graal; - -import java.awt.Graphics; -import java.awt.GraphicsEnvironment; - -import com.oracle.svm.core.annotate.AlwaysInline; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -@TargetClass(GraphicsEnvironment.class) -final class Target_java_awt_GraphicsEnvironment { - @AlwaysInline("DCE for things using Java2D") - @Substitute - public static Graphics getLocalGraphicsEnvironment() { - throw new UnsupportedOperationException("Not implemented yet for GraalVM native images"); - } -} - -class Java2DSubstitutions { -}