RFR: 8355080: java.base/jdk.internal.foreign.SystemLookup.find() doesn't work on static JDK
Chen Liang
liach at openjdk.org
Tue Apr 22 21:35:44 UTC 2025
On Tue, 22 Apr 2025 21:08:56 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:
> Please review this PR that changes to use `NativeLibraries.loadLibrary()` for loading the `libsyslookup` in `jdk.internal.foreign.SystemLookup` class.
>
> `NativeLibraries.loadLibrary()` handles both the shared library and (static) built-in library loading properly. On `static-jdk`, calling `NativeLibraries.loadLibrary()` for `systlookup` library can find the built-in library by looking up using `JNI_OnLoad_syslookup`. The current change adds `DEF_STATIC_JNI_OnLoad` in syslookup.c (in shared, windows and aix versions) for that purpose.
>
> In addition to GHA testing, I tested the change on static-jdk with jdk tier1 tests on linux-x64 locally. All java/foreign/* jdk tier1 tests pass with the change. Without the change, there are about 60 java/foreign/* jdk tier1 tests fail on static-jdk.
`sysLookup` does look much cleaner compared to `jdkLibraryPath`.
src/java.base/share/classes/jdk/internal/foreign/SystemLookup.java line 135:
> 133: @SuppressWarnings("restricted")
> 134: private static SymbolLookup sysLookup() {
> 135: NativeLibraries libs = jdk.internal.loader.NativeLibraries.newInstance(null);
Suggestion:
NativeLibraries libs = NativeLibraries.newInstance(null);
We already imported this class.
-------------
PR Review: https://git.openjdk.org/jdk/pull/24801#pullrequestreview-2785431747
PR Review Comment: https://git.openjdk.org/jdk/pull/24801#discussion_r2054915197
More information about the core-libs-dev
mailing list