FMA-17 MemorySegment needs a isNative()

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Apr 20 09:57:47 UTC 2021


We'll consider this.

In the meantime, you can emulate the check with this:

try {
    segment.address().toRawLongValue()
    return true;
} catch (UnsupportedOperationException ex) {
    return false;
}

Not great, but works :-)

Maurizio


On 20/04/2021 00:29, leerho wrote:
> It would be very useful to be able to determine from just a given
> MemorySegment if it is off-heap or on-heap.  If a custom allocator gets a
> request from a child process for a new segment, the allocator needs to know
> whether that segment should be allocated on-heap or off-heap.
>
> A simple *boolean isNative() would do the trick.*
>
> Lee.


More information about the panama-dev mailing list