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

Daniel Fuchs daniel.fuchs at oracle.com
Fri Feb 7 16:56:25 UTC 2020


Hi Brian,

           [...] If the source buffer is this buffer and
1139      * the source and target intervals overlap, then the buffer 
elements in the
1140      * target range will be overwritten by those in the source 
range of the
1141      * same buffer which could lead to unexpected results.

I wonder if the text should be a bit more generic here - as I suspect
it's also true if the source buffer is a *view* of the destination
buffer - that is - if the backend storage is the same for both buffers?

best regards,

-- daniel

On 29/01/2020 23:49, Brian Burkhalter wrote:
> Please consider this prototype fix [1] for [2]. The other potential method
> 
> $Type$Buffer put(int index, $Type$Buffer src) {}
> 
> mentioned in the issue description is not included here so as to avoid mixing relative bulk (for src) and absolute bulk (for this) operations, i.e., not having either buffer change state. The proposed method therefore simply is the equivalent of replacing the array parameter $type$[] of $Type$Buffer.put(int, $type$[], int, int) with a $Type$Buffer.
> 
> More performant implementations specific to heap and direct buffers are intentionally omitted at this time but will be added later if this concept moves forward.
> 
> One potentially problematic behavior in the proposed method is allowing overlapping source and target ranges when the source and target buffers are the same buffer.
> 
> Thanks,
> 
> Brian
> 
> [1] http://cr.openjdk.java.net/~bpb/8219014/webrev.00/
> [2] https://bugs.openjdk.java.net/browse/JDK-8219014
> 



More information about the nio-dev mailing list