[foreign-preview] RFR: 8282873: Bring back SymbolLookup

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Mar 9 11:22:01 UTC 2022


This patch brings back the `SymbolLookup` abstraction, which was initially left behind during the move to java.base.

In hindsight, moving lookup capabilities to `CLinker` and `ClassLoader`, while economical in terms of API surface, is problematic, as it is much harder to users of the API to understand how to look up for library symbols (since lookup capabilities are scattered across different classes).

Moreover, recent JDK changes, such as JDK-8281335 and JDK-8282608, make library loading more flexible, and much closer to a raw dlopen/dlsym/dlclose. Which means we can now provide, in addition to loader and system lookup, a *third* kind of lookup, which features deterministic library loading/unloading (see `SymbolLoojup::libraryLookup`).

Overall, I think that having a dedicated abstraction for looking up symbols in libraries is a good thing; not only it makes the API more discoverable, but it also allows clients to define custom lookup (as `SymbolLookup` is a simple functional interface).

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

Commit messages:
 - Remove whitespaces
 - Improve javadoc
 - Merge branch 'foreign-preview' into symbol_lookup_reloaded
 - Tweak javadoc of SymbolLookup
 - Tweak SymbolLookup javadoc
 - Fix package javadoc
 - Fix benchmarks
 - All tests pass
 - Add test comment
 - Initial push
 - ... and 8 more: https://git.openjdk.java.net/panama-foreign/compare/b1020d11...67f24809

Changes: https://git.openjdk.java.net/panama-foreign/pull/666/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=666&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8282873
  Stats: 605 lines in 40 files changed: 451 ins; 71 del; 83 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/666.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/666/head:pull/666

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


More information about the panama-dev mailing list