[foreign-memaccess+abi] RFR: 8266814: Improve library loading with SymbolLookup abstraction

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon May 10 14:29:18 UTC 2021

This patch implements the library loading abstraction described in:


That is, a functional interface called `SymbolLookup`, and a couple of factories to get a lookup for a given classloader, and to get a *system* lookup, useful to lookup C symbols.

To implement the system lookup, we load `msvcrt.dll` on Windows, while we build and load an empty library (which depends on libc) on Mac/Linux. This approach is better than relying on RTLD_DEFAULT (which can sometimes leak symbols from libraries loaded independently). Also, doing this bypasses the problem of figuring out the location of libc, which, on Linux system is particularly gnarly, because of the multi-arch support.


Commit messages:
 - Javadoc fixes
 - Fix whitespaces
 - Merge branch 'foreign-memaccess+abi' into symbol_lookup
 - Add CallerSensitive method for getting lookup for current class loader
 - Rename c library for suporting system lookup
 - Initial push

Changes: https://git.openjdk.java.net/panama-foreign/pull/531/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=531&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8266814
  Stats: 744 lines in 30 files changed: 390 ins; 293 del; 61 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/531.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/531/head:pull/531

PR: https://git.openjdk.java.net/panama-foreign/pull/531

More information about the panama-dev mailing list