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

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


On Thu, 17 Sep 2020 13:52:29 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

>> 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.
>
> src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/resources/RuntimeHelper.java.template line 70:
> 
>> 68:     }
>> 69:
>> 70:     static class RunnableHolder implements Runnable {
> 
> Should this be called SymbolHolder?

yeah... will fix

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

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


More information about the panama-dev mailing list