[foreign-memaccess+abi] RFR: Add support for high-level functions to copy to and from Java arrays [v2]

John Rose john.r.rose at oracle.com
Thu Jun 24 18:19:38 UTC 2021


On Jun 24, 2021, at 2:47 AM, Maurizio Cimadamore <mcimadamore at openjdk.java.net<mailto:mcimadamore at openjdk.java.net>> wrote:

There's only one length - it's important to distinguish between Chars vs. Bytes - e.g. copyLengthChars vs. copyLengthBytes. But adding the `src` seems confusing because the `length` parameter is, IMHO neutral, and just indicates how many "things" have to be bulk-copied.

In fact, I'll go further and say that, when editing this patch I kept finding the placement of the length argument confusing. Having it as the trailing argument would be clearer IMHO.

Totally agree.  The length parameter applies equally
to source and destination.  Perhaps also rename length
as ‘count’ to make it more clear that we are counting items,
not measuring memory spans.

Putting length/count last is coherent with System.arraycopy.
That’s not a beautiful API but it is one that everybody knows.


More information about the panama-dev mailing list