RFR: JDK-8275703: System.loadLibrary fails on Big Sur for libraries hidden from filesystem
Jaikiran Pai
jpai at openjdk.java.net
Wed Oct 27 03:42:08 UTC 2021
On Wed, 27 Oct 2021 03:31:00 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> On, macOS 11.x, system libraries are loaded from dynamic linker cache. The libraries are no longer present on the filesystem. `NativeLibraries::loadLibrary` checks for the file existence before calling `JVM_LoadLibrary`. Such check no longer applies on Big Sur. This proposes that on macOS >= 11, it will skip the file existence check and attempt to load a library for each path from java.library.path and system library path.
>
> src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 166:
>
>> 164: return null;
>> 165: }
>> 166: return file.getCanonicalPath();
>
> I think a `!file.exists()` check would still be needed here to handle the case when `loadLibraryOnlyIfPresent` is `false`, isn't it?
Ignore this previous comment. I read your JBS comment just now which says:
> The JDK side determines the path of the given library name and checks if it exists before calling JVM_LoadLibrary. A potential fix for MacOS might be to skip the file presence check and pass it to JVM.
So, I think, the whole point of this change in this block is to skip the file existence check and return back a file path.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6127
More information about the core-libs-dev
mailing list