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

Brian Burkhalter brian.burkhalter at oracle.com
Fri Feb 7 17:18:50 UTC 2020


Hi Daniel,

> On 07/02/2020 17:02, Brian Burkhalter wrote:
>> If it is a view then it should be either a read-only buffer of the same type as the target, or a buffer of a different type in which case it would cause a compilation error. So I don’t know about that this verbiage change would be called for, unless I am missing something.
> 
> Well - I am not sure I understand what said verbiage means then.
> Assuming:
> 
>  byte[] bytes = ....;
> 
>  var b1 = ByteBuffer.wrap(bytes);
>  var b2 = ByteBuffer.wrap(bytes);
>  var b3 = b1.asReadOnly();
> 
>  b2.put(1, b1, 0, len-1);
>  b1.put(1, b3, 0, len-1);
> 
> wouldn't any of these put you in the exact same troublesome
> situation as:
> 
>  b2.put(1, b2, 0, len-1);

I see what you mean. Then something like “if the source buffer is backed by the same storage as this buffer” might cover it.

Thanks,

Brian


More information about the nio-dev mailing list