RFR: 8281335: Allow a library already loaded via System::loadLibrary to be loaded as a raw library

Athijegannathan Sundararajan sundar at openjdk.java.net
Fri Feb 11 02:43:09 UTC 2022


On Thu, 10 Feb 2022 23:27:49 GMT, Mandy Chung <mchung at openjdk.org> wrote:

> This patch removes the restriction in the raw library loading mechanism that does not allow mix-n-match of loading a library as a JNI library and as a raw library.
> 
> The raw library loading mechanism is designed for panama to load native library essentially equivalent to dlopen/dlclose calls independent of JNI library loading. If a native library is loaded as a JNI library and a raw library, it will get different NativeLibrary instances. When a class loader is being unloaded, JNI_Unload will be invoked but the native library may not be unloaded until NativeLibrary::unload is explicitly called for the raw library.

LGTM

src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 58:

> 56:  * will fail.
> 57:  */
> 58: public abstract class NativeLibraries {

could this be sealed with only two specific subtypes defined here?

src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java line 251:

> 249:             // do not search java.library.path
> 250:             super(loader, loader != null ? null : NativeLibraries.class,
> 251:                     loader != null ? true : false);

The last argument expression of the super class could be just loader != null

-------------

Marked as reviewed by sundar (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/7435


More information about the core-libs-dev mailing list