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

Load jawt library relative to sun.boot.library.path system on unix OSes #1422

Merged

Conversation

matthiasblaesing
Copy link
Member

At least Ubuntu builds the JDK with RUNPATH set instead of RPATH. The
two differ in their effect on loading transitive dependencies.

RPATHs effect also covers libraries loaded as transitive dependencies,
while RUNPATH does not. In the case of JNA libjawt is loaded by
libdispatch (the native JNA part), which makes it a transtive load.

The solution is to load the library with the full path based on the
sun.boot.library.path system property, which points to the native
library dirs.

@matthiasblaesing matthiasblaesing force-pushed the jawt_loading_fix branch 3 times, most recently from fd806d3 to 5fe6a2c Compare March 13, 2022 19:21
@matthiasblaesing
Copy link
Member Author

@neilcsmith-net this implementation is shamelessly based on your idea from here:

https://groups.google.com/g/jna-users/c/h1WyVnq2vUQ/m/rvP5d7XSCgAJ

I tested this with JDK 7, 8, 11 (OpenJDK builds) on Linux, with JDK 8 and 11 from Ubuntu Linux and with OpenJDK 8 builds on windows (to verify no negative effects on Windows).

@neilcsmith-net
Copy link
Contributor

neilcsmith-net commented Mar 14, 2022

@matthiasblaesing 👍 well, my shame is not yet getting around to a PR! 😄

I have to say my approach would have been slightly different, to do this on the Java side inside Native.AWT. Partly based on your desire not to update the native libs, and partly because I've always thought it better to try and achieve things on the Java side anyway.

Either way, fix highly appreciated! Thanks.

@matthiasblaesing
Copy link
Member Author

Not having to modify native is always a good argument, one argument to look into this now was, that a fix for crash issues on mac OS M1 will need rebuilds anyway.

At least Ubuntu builds the JDK with RUNPATH set instead of RPATH. The
two differ in their effect on loading transitive dependencies.

RPATHs effect also covers libraries loaded as transitive dependencies,
while RUNPATH does not. In the case of JNA libjawt is loaded by
libdispatch (the native JNA part), which makes it a transtive load.

The solution is to load the library with the full path based on the
sun.boot.library.path system property, which points to the native
library dirs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants