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

Print exception details/stacktrace when failed to add a library #8888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Eng-Fouad
Copy link

Resolves #8887

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 7, 2024
@selhagani selhagani self-assigned this May 9, 2024
@selhagani
Copy link
Member

Hey @Eng-Fouad, Thank you for your contribution!

@wirthi Could you please assign this to someone that can review this PR. Thanks a lot!

@wirthi wirthi requested a review from peter-hofer May 10, 2024 07:24
@@ -146,6 +146,7 @@ private boolean loadLibrary0(File file, boolean builtin) {
String canonical = builtin ? file.getName() : file.getCanonicalPath();
return addLibrary(canonical, builtin);
} catch (IOException e) {
e.printStackTrace();
Copy link
Member

Choose a reason for hiding this comment

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

We don't know where the library is supposed to be and this method is used for probing, so adding this might print several unhelpful stack traces even when the library can ultimately be loaded. I believe the behavior is the same in OpenJDK, see jdk.internal.loader.NativeLibraries#loadLibrary(java.lang.Class<?>, java.io.File).

Copy link
Author

@Eng-Fouad Eng-Fouad May 29, 2024

Choose a reason for hiding this comment

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

@peter-hofer At least print it with debug level if possible instead of hiding the exception details entirely.

I faced a problem in the past when trying to load awt in native image. I got the message UnsatisfiedLinkError: Can't load library: awt which didn't help me to identify the real cause. After several days, I solved the problem by including other .so shared libs (beside libawt.so I had to include libawt_headless.so, libawt_xawt.so, libjava.so, libjvm.so) and registering few methods in jni-config.json (extracted by the help of tracing agent).

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.

Print exception details/stacktrace when failed to add a library
3 participants