[foreign-memaccess+abi] RFR: 8270376: Finalize API for memory copy [v9]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri Aug 6 18:21:40 UTC 2021


On Fri, 6 Aug 2021 17:38:30 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

> Re: `MemorySegment.toXArray`, yes good point. I think we could remove these. They are a bit like the `Arrays.copyOf/Range` methods. Not suggesting we such methods.

I'm less sure about this now - on the one hand these are clearly redundant. On the other hand, there is a symmetry between MemorySegment::ofArray(XYZ[]) and MemorySegment::toXYZArray().

Another option would be to just expose a `toByteArray`, e.g. just expose a basic byte view of the segment (after all a segment is just a bag of bytes), which would be consistent with the decision of only exposing `asByteBuffer` (although it's easier to go from, say, a ByteBuffer to an IntBuffer than it is to go from a byte array to an int array).

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

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


More information about the panama-dev mailing list