[foreign-memaccess+abi] RFR: API refresh - part two

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Oct 5 21:28:24 UTC 2021


On Tue, 5 Oct 2021 20:54:34 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> After playing a bit more with the new API changes, I realized there were issues with some of the solutions proposed in [1].
> I will add more details in a separate comment, to keep the header of this PR compact.
> 
> [1] - https://git.openjdk.java.net/panama-foreign/pull/576

This is is an example where having `ResourceScope <: SegmentAllocator` is a bit problematic:


try (ResourceScope scope = ResourceScope.newConfinedScope()) {
   SegmentAllocator allocator = SegmentAllocator.newArena(scope);
   MemorySegment segment = allocator.allocate(10); // (2)
}

Note that, in (2) the client has two allocators available: the scope and the arena - even though the code is probably meant to use the arena from that point on.

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

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


More information about the panama-dev mailing list