RFR: JDK-8293659: Improve UnsatisfiedLinkError error message to include dlopen error details [v2]
Mandy Chung
mchung at openjdk.org
Tue Sep 20 17:15:57 UTC 2022
On Fri, 16 Sep 2022 07:27:44 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:
>> When trying to load a x64 lib on macOS aarch64 one got previously this detailed message before [JDK-8275703](https://bugs.openjdk.org/browse/JDK-8275703):
>>
>> java.lang.UnsatisfiedLinkError: /testing/jco3/macOsx64/libsapjco3.dylib: dlopen(/testing/jco3/macOsx64/libsapjco3.dylib, 1): no suitable image found. Did find:
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
>
> Adjust throwExceptionIfFail
If you load a library via `System::load`, it only loads the given file path which must be an absolute path name. In this case, it only calls `JVM_LoadLibrary` once and also it will use dlopen's error message if it fails to load it.
If loading a library via `System::loadLibrary`, it will search through the library paths and system library paths and `UnsatisfiedLinkException` will be thrown if either (1) no file exists and not present in the dynamic cache or (2) a named library exists but fail to load.
The case when `JVM_LoadLibrary` is called without exception is to allow the search through the library path (e.g. `dir1:dir2`) that libFoo does not exist in `dir1` and `dir2` but `dir2/libFoo` is present in the dynamic cache.
-------------
PR: https://git.openjdk.org/jdk/pull/10286
More information about the core-libs-dev
mailing list