Skip to content

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

Merged
matthiasblaesing merged 1 commit intojava-native-access:masterfrom
matthiasblaesing:jawt_loading_fix
Mar 14, 2022
Merged

Load jawt library relative to sun.boot.library.path system on unix OSes#1422
matthiasblaesing merged 1 commit intojava-native-access:masterfrom
matthiasblaesing:jawt_loading_fix

Conversation

@matthiasblaesing
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants