8219014: (bf) Add absolute bulk put methods which accept a source Buffer

Paul Sandoz paul.sandoz at oracle.com
Fri Jun 26 16:25:15 UTC 2020


Given the prior and ongoing progress of the incubating MemorySegment API, it’s easy to transfer from BB to MS to perform the bulk copy. 

  ByteBuffer b1 = ByteBuffer.allocate(16);
  ByteBuffer b2 = ByteBuffer.allocate(16);
  MemorySegment.ofByteBuffer(b1).copyFrom(MemorySegment.ofByteBuffer(b2));

(With some marginal allocation cost.)

However, that leaves out the other buffers and views on BB, and buffers are still and will be widely used.

You previous work laid the foundations such that this feature is predominantly API and test work (and ensuring that annoying buffer backed by CharSequence or String, I forget which, is not misbehaving).

I am inclined to proceed.

Paul.

> On Jun 25, 2020, at 5:42 PM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
> 
> Reviving [1] from April.
> 
>> On Apr 1, 2020, at 8:57 AM, Brian Burkhalter <brian.burkhalter at oracle.com <mailto:brian.burkhalter at oracle.com>> wrote:
>> 
>>> Hmm.  This part
>>> 
>>> +     * of both buffers are unchanged. If the source buffer and this buffer share
>>> +     * the same backing storage and the source and destination ranges overlap,
>>> +     * then the transfer is performed as if the elements at positions
>>> 
>>> still references “backing storage”?  Should it say “backing array”
>>> instead?
>>> 
>>> I don't think you can make such a promise for direct buffers.
>> 
>> I think the fallback code that does put(j, get(i)) instead of using arraycopy() or Unsafe needs to be checked for this, but the latter two approaches insofar as we know will handle overlaps.
> 
> If we are interested in resolving [2], then it is much easier after the fix for [3]. A possible change is [4]. If this seems reasonable then testing will be added and a CSR filed; if not, then perhaps withdraw the issue.
> 
> Thanks,
> 
> Brian
> 
> [1] http://mail.openjdk.java.net/pipermail/nio-dev/2020-April/007154.html <http://mail.openjdk.java.net/pipermail/nio-dev/2020-April/007154.html>
> [2] https://bugs.openjdk.java.net/browse/JDK-8219014 <https://bugs.openjdk.java.net/browse/JDK-8219014>
> [3] https://bugs.openjdk.java.net/browse/JDK-8245121 <https://bugs.openjdk.java.net/browse/JDK-8245121>
> [4] http://cr.openjdk.java.net/~bpb/8219014/webrev.02/ <http://cr.openjdk.java.net/~bpb/8219014/webrev.02/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20200626/317850c1/attachment-0001.htm>


More information about the nio-dev mailing list