RFR: 8283060: RawNativeLibraries should allow multiple clients to load/unload the same library
Mandy Chung
mchung at openjdk.java.net
Tue Mar 29 20:14:25 UTC 2022
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.
-------------
Commit messages:
- 8283060: RawNativeLibraries should allow multiple clients to load/unload the same library
Changes: https://git.openjdk.java.net/jdk/pull/8022/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8022&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8283060
Stats: 66 lines in 3 files changed: 43 ins; 10 del; 13 mod
Patch: https://git.openjdk.java.net/jdk/pull/8022.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/8022/head:pull/8022
PR: https://git.openjdk.java.net/jdk/pull/8022
More information about the core-libs-dev
mailing list