[foreign-memaccess] RFR 8227394: Add MemorySegment::asByteBuffer convenience method
Jorn Vernee
jbvernee at xs4all.nl
Fri Jul 12 19:37:40 UTC 2019
In almost all the the cases we already had access to the MemorySegment,
so we could just call asByteBuffer() directly on that. The only case
where we couldn't is in TestNative on line 114, since we only have
access to the MemoryAddress, not the segment. We have to use the new
`offset()` method to make a slice first, and then call asByteBuffer() on
the slice:
ByteBuffer bb = base.segment().slice(base.offset(),
(int)layout.byteSize()).asByteBuffer();
We still end up using asByteBuffer() though, but it's not as much a
1-to-1 change there. Probably should have just said "Updated tests to
use the new asByteBuffer()".
Jorn
On 2019-07-12 18:50, Maurizio Cimadamore wrote:
> On 12/07/2019 16:26, Jorn Vernee wrote:
>> * Updated tests to use the new asByteBuffer where possible (all but
>> one)
>
> Can you expand a bit on this?
>
> Thanks
> Maurizio
More information about the panama-dev
mailing list