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

[GR-46526] Preserve LinkageErrors and re-throw them at run-time. #6753

Closed
wants to merge 4 commits into from

Conversation

graalvmbot
Copy link
Collaborator

Run-time example:

$ ./gameoflife.main 
Exception in thread "main" java.lang.UnsupportedClassVersionError: Preview features are not enabled for gameoflife/GameOfLife (class file version 64.65535). Try running with '--enable-preview'
	at gameoflife.Main.main(Main.java:43)

Build-time example:

...
Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: gameoflife.GameOfLife. This error is reported at image build time because class gameoflife.Main is registered for linking at image build time by command line.
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:554)
...
Caused by: java.lang.UnsupportedClassVersionError: Preview features are not enabled for gameoflife/GameOfLife (class file version 64.65535). Try running with '--enable-preview'
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
...

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 7, 2023
@fniephaus fniephaus requested a review from zakkak June 7, 2023 11:19
@fniephaus
Copy link
Member

@zakkak could you maybe run some Quarkus samples and report how many LinkageErrors there are? Maybe we also want an option to print those somehow.

@@ -845,6 +845,10 @@ private void handleClassFileName(URI container, Module module, String className)
clazz = imageClassLoader.forName(className, module);
} catch (AssertionError error) {
VMError.shouldNotReachHere(error);
} catch (LinkageError le) {
synchronized (linkageErrors) {
linkageErrors.put(className, le);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should make sure that the LinkageError does not reference another Throwable to prevent leakage?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that risk losing the root cause?

To my understanding LinkageError may only reference another Throwable through the cause field.

@zakkak
Copy link
Collaborator

zakkak commented Jun 7, 2023

@zakkak could you maybe run some Quarkus samples and report how many LinkageErrors there are? Maybe we also want an option to print those somehow.

Sure, I will try to do some tests tomorrow, otherwise it will have to wait ~2 weeks.

@zakkak
Copy link
Collaborator

zakkak commented Jun 8, 2023

@zakkak could you maybe run some Quarkus samples and report how many LinkageErrors there are? Maybe we also want an option to print those somehow.

I am appending the results from a simple Java helloworld and some "beefy" scenarios from https://github.com/quarkus-qe/beefy-scenarios.

Test LinkageErrors
HelloWorld 0
'001-quarkus-getting-started-with-jaxrs-1.0.0-SNAPSHOT-runner' 61
'003-quarkus-many-extensions-1.0.0-SNAPSHOT-runner' 472
'004-quarkus-HHH-and-HV-1.0.0-SNAPSHOT-runner' 68
'005-quarkus-and-maven-profiles-1.0.0-SNAPSHOT-runner' 82
'006-quartz-manually-scheduled-job-1.0.0-SNAPSHOT-runner' 62
'010-quarkus-opentracing-reactive-grpc-1.0.0-SNAPSHOT-runner' 54
'011-quarkus-panache-rest-flyway-1.0.0-SNAPSHOT-runner' 66
'014-quarkus-panache-with-transactions-xa-1.0.0-SNAPSHOT-runner' 403
'015-quarkus-micrometer-1.0.0-SNAPSHOT-runner' 99
'017-quartz-cluster-1.0.0-SNAPSHOT-runner' 79
'018-quarkus-runtime-properties-1.0.0-SNAPSHOT-runner' 33
'019-quarkus-consul-1.0.0-SNAPSHOT-runner' 32
'020-quarkus-http-non-application-endpoints-1.0.0-SNAPSHOT-runner' 100
'021-quarkus-panache-multiple-pus-1.0.0-SNAPSHOT-runner' 54
'022-quarkus-properties-config-all-1.0.0-SNAPSHOT-runner' 49

@zakkak
Copy link
Collaborator

zakkak commented Jul 12, 2023

Hi @fniephaus , are there any updates on this?

@fniephaus
Copy link
Member

No, not at this point. We have an idea that no longer requires a static map, but I haven't had enough time to look into this yet.

@zakkak
Copy link
Collaborator

zakkak commented Jun 18, 2024

Hi @fniephaus, we hit that issue again in quarkusio/quarkus#41256 (comment)

Are there any plans on merging a fix for it?

@fniephaus
Copy link
Member

Hi @zakkak, the PR is unfortunately not in the best state and more changes are needed. I wish I had more time for this but I'm afraid it's currently not a priority. Closing the PR for now

@fniephaus fniephaus closed this Aug 18, 2024
@zakkak
Copy link
Collaborator

zakkak commented Oct 8, 2024

No, not at this point. We have an idea that no longer requires a static map, but I haven't had enough time to look into this yet.

@fniephaus could you share more info on this so that I could evaluate whether it's something I could contribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants