[foreign-jextract] RFR: 8253290: Tweak jextract code to use new MemoryAddress::asSegmentRestricted

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Sep 17 13:57:20 UTC 2020


This fixes references to the now-removed MemorySegment::ofNativeRestricted(...).

The only tricky issue is in RunimeHelper - which has to create an unchecked segment for a global variable and,
in doing so, it has to keep a reference of the lookup symbol in there, to prevent the library from being unloaded.

Since the new API doesn't have an explicit way to add an attachment, I've added a simple Runnable impl which wraps a
symbol, and pass that as a no-op cleanup action to the segment.

For the records, I believe that creating segments for global vars is tricky enough that there should be a blessed
(restricted) way to do that in the LibraryLookup.Symbol API.

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

Commit messages:
 - Fix references to reactored MemorySegment::ofNativeRestricted

Changes: https://git.openjdk.java.net/panama-foreign/pull/335/files
 Webrev: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=335&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8253290
  Stats: 41 lines in 3 files changed: 29 ins; 2 del; 10 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/335.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/335/head:pull/335

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


More information about the panama-dev mailing list