RFR: 8355080: java.base/jdk.internal.foreign.SystemLookup.find() doesn't work on static JDK

Jiangli Zhou jiangli at openjdk.org
Tue Apr 22 21:14:16 UTC 2025


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.

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

Commit messages:
 - Use NativeLibraries.loadLibrary() to get the libsyslookup. This works on both regular and static JDK.

Changes: https://git.openjdk.org/jdk/pull/24801/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24801&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8355080
  Stats: 40 lines in 5 files changed: 23 ins; 7 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/24801.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24801/head:pull/24801

PR: https://git.openjdk.org/jdk/pull/24801


More information about the core-libs-dev mailing list