The default java.library.path on Linux does not include the library paths in the mulitarch-spec
David Holmes
david.holmes at oracle.com
Tue Jan 2 02:07:54 UTC 2024
Hi Glavo,
On 24/12/2023 4:18 am, Glavo wrote:
> Hi,
>
> There are already many Linux distributions that are following the
> multiarch-spec[1] and adding the following paths to the default library
> path list:
>
> * /usr/local/lib/<triplet>
> * /lib/<triplet>
> * /usr/lib/<triplet>
>
> But OpenJDK doesn't add these paths to the java.library.path by default,
> so System.loadLibrary(String) has annoying behavior differences with ld.
AFAICS java.library.path (and sun.boot.library.path) are input
properties that can be set by the user. There are no "default" values
for these properties as such. The library loading will ultimately rely
on the behaviour of dlopen, if no additional paths have been set, so it
seems to me what you really want is for dlopen to act "the same way"
that ld does. Note that dlopen will already check the contents of
/etc/ld.so.cache
> Many libraries already installed on the system cannot be found by
> System.loadLibrary(String).
>
> I wish OpenJDK would parse the /etc/ld.so.conf to get the full library
> path list so it would be consistent with the behavior of ld.
> Can anyone consider this suggestion?
This does not seem practical. On my system ld.so.conf just contains
include ld.so.conf.d/*.conf
so now we (hotspot) have to read the top-level file, parse it, interpret
it and then recursively read, parse and interpret more files.
Cheers,
David
----
> Glavo
>
> [1]: https://wiki.ubuntu.com/MultiarchSpec
> <https://wiki.ubuntu.com/MultiarchSpec>
More information about the core-libs-dev
mailing list