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 amazon extensions results in unregistered resource or reflective accesses in native mode #44656

Open
zakkak opened this issue Nov 22, 2024 · 1 comment
Labels
area/native-image kind/bug Something isn't working

Comments

@zakkak
Copy link
Contributor

zakkak commented Nov 22, 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:

...

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access

   io.quarkus.it.amazon.lambda.TestLambda.getMethods()

without it being registered for runtime reflection. Add io.quarkus.it.amazon.lambda.TestLambda.getMethods() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
  java.base@24/java.lang.Class.getMethods(DynamicHub.java:1120)
  io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.discoverHandlerMethod(AmazonLambdaRecorder.java:95)
  io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.initializeHandlerClass(AmazonLambdaRecorder.java:56)
  io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder.chooseHandlerClass(AmazonLambdaRecorder.java:161)
  io.quarkus.deployment.steps.AmazonLambdaProcessor$recordHandlerClass308924844.deploy_0(Unknown Source)
  io.quarkus.deployment.steps.AmazonLambdaProcessor$recordHandlerClass308924844.deploy(Unknown Source)
  io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
  io.quarkus.runtime.Application.start(Application.java:101)

...

org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively access method

   java.net.UnknownHostException#<init>(java.lang.String)

without it being registered for runtime reflection. Add java.net.UnknownHostException#<init>(java.lang.String) to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
  java.base@24/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:506)
  io.quarkus.amazon.lambda.runtime.AbstractLambdaPollLoop$1.run(AbstractLambdaPollLoop.java:99)
  java.base@24/java.lang.Thread.runWith(Thread.java:1460)
  java.base@24/java.lang.Thread.run(Thread.java:1447)
  org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:832)
  org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:808)

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/amazon-lambda \
    -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 22, 2024
Copy link

quarkus-bot bot commented Nov 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/native-image kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant