FMA-17 MemorySegment needs a isNative()
Chris Vest
mr.chrisvest at gmail.com
Tue May 11 13:20:38 UTC 2021
Thanks, I had missed that it had already been added to panama-foreign.
On Tue, 11 May 2021 at 11:45, Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> wrote:
> Hi,
> the method has been added in the latest API iteration and is slated for
> integration here:
>
> https://git.openjdk.java.net/jdk/pull/3699
>
> Thanks
> Maurizio
> On 11/05/2021 10:22, Chris Vest wrote:
>
> For what it's worth we have a similar try-catch in the Netty integration.
> We have a method on our Buffer interface for querying a buffers native
> address, which returns 0 as a special value for heap buffers.
> We use this information to decide how to do certain IO calls.
>
> On Tue, 20 Apr 2021 at 11:58, Maurizio Cimadamore <
> maurizio.cimadamore at oracle.com> wrote:
>
>> 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