[foreign-memaccess+abi] Integrated: 8264386: LibraryLookup should be more friendly with implicit unloading
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Mon Mar 29 23:47:44 UTC 2021
On Mon, 29 Mar 2021 15:36:13 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> Quoting from the PR:
>
> Dereferencing a segment from a LibraryLookup is possible, in the following form:
>
> LibraryLookup libLookup = ...
> MemorySegment segment = libLookup.lookup("foo").asSegmentRestricted(....)
>
> The above code has a problem: there is no link between the produced segment and the original library lookup - meaning that, in principle, it's possible for the library to be unloaded when dereference occurs.
>
> After having discussed many alternatives with Jorn, the best way to address this conundrum would be to add an overload of `LibraryLookup::lookup` which takes a lyout and returns a segment.
>
> As part of this change I have also removed the LibraryLookup.Symbol API which seems unnecessary - now you can lookup an address or a segment. Of course, looking up a segment is creating a restricted segment (so it should be treated as unsafe).
>
> I've added a test to make sure that the new API works as expected.
This pull request has now been integrated.
Changeset: d70c1e40
Author: Maurizio Cimadamore <mcimadamore at openjdk.org>
URL: https://git.openjdk.java.net/panama-foreign/commit/d70c1e40
Stats: 126 lines in 11 files changed: 48 ins; 30 del; 48 mod
8264386: LibraryLookup should be more friendly with implicit unloading
Reviewed-by: psandoz, jvernee
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/480
More information about the panama-dev
mailing list