java 14 and JEP 370: Foreign-Memory Access API-- Array Of Bytes.
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Mar 25 16:32:59 UTC 2020
Yeah - I now realize I did not reply to the original question.
The way to go to do bulk access is to use the MemoryAddress::copy API,
as shown in the email from Henry.
That is:
1) create an on-heap segment backed by a byte[]
2) copy portions of the off-heap segment into the on-heap segment using
MemoryAddress:copy
Maurizio
On 25/03/2020 15:58, Ty Young wrote:
> They seem to want a method that accepts an array of bytes(byte[])
> which is then put into memory and then be able to get it back without
> accessing individual offset locations or using ByteBuffer.
>
>
> There is no such thing for setting AFAIK. The MemorySegment.ofArray()
> methods just create a MemorySegment that can hold an array of the
> given array's size AFAIK.
>
>
> There is a method for getting the array in bulk though:
> <MemorySegment>.toByteArray().
>
>
More information about the panama-dev
mailing list