RFR: 8283060: RawNativeLibraries should allow multiple clients to load/unload the same library
Jorn Vernee
jvernee at openjdk.java.net
Wed Mar 30 11:54:37 UTC 2022
On Tue, 29 Mar 2022 20:05:50 GMT, Mandy Chung <mchung at openjdk.org> wrote:
> A small improvement to `RawNativeLibraries`. `RawNativeLibraries::load` returns the same `NativeLibrary` instance of a given path if it's called multiple times. This means that multiple clients have to coordinate that the last one using the loaded library is the one to close the library by calling `RawNativeLibraries::unload`; otherwise, an exception may be thrown.
>
> This patch changes `RawNativeLibraries::load` to delegate to the underlying platform-specific library loading mechanism e.g. dlopen/dlclose that keeps the reference count. So each call to `RawNativeLibraries::load` and `unload` is simply a call to dlopen and dlclose respectively. Each client of calling `RawNativeLibraries::load` is responsible for calling `RawNativeLibraries::unload`. This will be consistent with the current behavior when you call `load` and `unload` with a different `RawNativeLibraries` instance.
Marked as reviewed by jvernee (Reviewer).
-------------
PR: https://git.openjdk.java.net/jdk/pull/8022
More information about the core-libs-dev
mailing list