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

io.quarkus.runner.AutoFeature hides exceptions thrown while registering resources and classes for JNI and reflective access #26162

Closed
zakkak opened this issue Jun 15, 2022 · 1 comment
Labels
area/native-image env/graalvm-java11 Relating to using GraalVM native image generation on Java 11 env/graalvm-java17 Relating to using GraalVM native generation Java 11 kind/bug Something isn't working

Comments

@zakkak
Copy link
Contributor

zakkak commented Jun 15, 2022

Describe the bug

io.quarkus.runner.AutoFeature hides exceptions thrown while registering resources and classes for JNI and reflective access.
This makes finding bugs on time harder.

Registering resources

for (NativeImageResourceBundleBuildItem i : resourceBundles) {
TryBlock et = overallCatch.tryBlock();
et.invokeVirtualMethod(ofMethod(Method.class, "invoke", Object.class, Object.class, Object[].class),
registerMethod, locSupport, et.marshalAsArray(Object.class, et.load(i.getBundleName())));
CatchBlockCreator c = et.addCatch(Throwable.class);
//c.invokeVirtualMethod(ofMethod(Throwable.class, "printStackTrace", void.class), c.getCaughtException());
}

Registering for reflection

//cc.invokeVirtualMethod(ofMethod(Throwable.class, "printStackTrace", void.class), cc.getCaughtException());

Registering for JNI access

//cc.invokeVirtualMethod(ofMethod(Throwable.class, "printStackTrace", void.class), cc.getCaughtException());

Expected behavior

Exceptions should be visible and ideally not thrown.

Actual behavior

Exceptions are actually thrown but never shown.

How to Reproduce?

Uncommenting the commented lines listed in the description will enable seeing the exceptions when building integration-tests with -Dnative.

Doing so results in prints like the following:

IT main

 java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at io.quarkus.runner.AutoFeature.registerClass18(Unknown Source)
	at io.quarkus.runner.AutoFeature.beforeAnalysis(Unknown Source)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:720)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:78)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:720)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:562)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:519)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:407)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:615)
java.lang.ClassNotFoundException: io.quarkus.smallrye.openapi.deployment.OpenApiConfigMapping
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at io.quarkus.runner.AutoFeature.registerClass453(Unknown Source)
	at io.quarkus.runner.AutoFeature.beforeAnalysis(Unknown Source)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:720)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:78)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:720)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:562)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:519)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:407)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:615)

IT hibernate-orm-tenancy

 java.lang.ClassNotFoundException: int
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at io.quarkus.runner.AutoFeature.registerClass39(Unknown Source)
	at io.quarkus.runner.AutoFeature.beforeAnalysis(Unknown Source)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:720)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:78)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:720)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:562)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:519)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:407)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:615)

hibernate-orm-panache

 java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at io.quarkus.runner.AutoFeature.registerClass23(Unknown Source)
	at io.quarkus.runner.AutoFeature.beforeAnalysis(Unknown Source)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$9(NativeImageGenerator.java:720)
	at com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:78)
	at com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:720)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:562)
	at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:519)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:407)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:615)

etc.

Output of uname -a or ver

No response

Output of java -version

11 and 17

GraalVM version (if different from Java)

22.1

Quarkus version or git rev

e644ded

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

No response

Additional information

No response

@zakkak zakkak closed this as completed Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/native-image env/graalvm-java11 Relating to using GraalVM native image generation on Java 11 env/graalvm-java17 Relating to using GraalVM native generation Java 11 kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants