Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The usage of the awt extension results in unregistered resource or reflective accesses in native mode #44622

Open
zakkak opened this issue Nov 21, 2024 · 1 comment

Comments

@zakkak
Copy link
Contributor

zakkak commented Nov 21, 2024

Describe the bug

As mentioned in #41995

Starting with Mandrel 23.0 (GraalVM for JDK 17) an option -H:+ThrowMissingRegistrationErrors was introduced to throw an exception

when it is impossible to tell whether a reflective query should fail because the queried element has not been registered at build-time, or because it doesn't exist.
...
Starting with Mandrel 24.1 (GraalVM for JDK 23) the option will be available as a public flag (meaning it's no longer experimental) with the intention to ultimately become the default.

Using this flat results in exceptions being thrown when using the awt extension as described below.

Expected behavior

No unregistered resource or reflective accesses should happen.

Actual behavior

The following unregistered resource or reflective accesses happen:
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource bundle with name

   sun.awt.resources.awt

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1410)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1407)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access class

   sun.awt.resources.spi.awtProvider

without it being registered for runtime reflection. Add sun.awt.resources.spi.awtProvider to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
  [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1410)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1407)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access class

   sun.awt.resources.awt

without it being registered for runtime reflection. Add sun.awt.resources.awt to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
  [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1410)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1407)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   sun/awt/resources/awt.properties

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1410)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1407)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access class

   sun.awt.resources.awt_en

without it being registered for runtime reflection. Add sun.awt.resources.awt_en to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
  [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1410)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1407)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   sun/awt/resources/awt_en.properties

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1410)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1407)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access class

   sun.awt.resources.awt_en_IE

without it being registered for runtime reflection. Add sun.awt.resources.awt_en_IE to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
  [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1410)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1407)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   sun/awt/resources/awt_en_IE.properties

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:858)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1410)
  [email protected]/java.awt.Toolkit$4.run(Toolkit.java:1407)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageInputStreamSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry$1.run(IIORegistry.java:216)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
  [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageTranscoderSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry$1.run(IIORegistry.java:216)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
  [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageWriterSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry$1.run(IIORegistry.java:216)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
  [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageReaderSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry$1.run(IIORegistry.java:216)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
  [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageOutputStreamSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry$1.run(IIORegistry.java:216)
  [email protected]/java.security.AccessController.executePrivileged(AccessController.java:132)
  [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageInputStreamSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:179)
  [email protected]/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:107)
  [email protected]/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:128)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageTranscoderSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:179)
  [email protected]/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:107)
  [email protected]/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:128)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageWriterSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:179)
  [email protected]/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:107)
  [email protected]/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:128)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageReaderSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:179)
  [email protected]/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:107)
  [email protected]/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:128)
com.oracle.svm.core.jdk.resources.MissingResourceRegistrationError: The program tried to access the resource at path

   META-INF/services/javax.imageio.spi.ImageOutputStreamSpi

without it being registered as reachable. Add it to the resource metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#resources-and-resource-bundles for help
  [email protected]/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1387)
  [email protected]/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:179)
  [email protected]/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:107)
  [email protected]/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:128)

How to Reproduce?

./mvnw clean package -Dnative -Dnative.surefire.skip \
    -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-23 \
    -Dquarkus.native.enable-reports -pl integration-tests/awt/ \
    -Dquarkus.native.additional-build-args=-H:ThrowMissingRegistrationErrors=
./integration-tests/awt/target/quarkus-integration-test-awt-999-SNAPSHOT-runner -XX:MissingRegistrationReportingMode=Warn

Tip

In GraalVM for JDK 24 the length of the printed stack trace when using -XX:MissingRegistrationReportingMode=Warn can be set with -XX:MissingRegistrationWarnContextLines=

Output of uname -a or ver

No response

Output of java -version

No response

Mandrel or GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@zakkak zakkak added area/native-image kind/bug Something isn't working labels Nov 21, 2024
Copy link

quarkus-bot bot commented Nov 21, 2024

/cc @Karm (awt,mandrel), @galderz (awt,mandrel)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant