RFC: 5029431: (bf) Add absolute bulk put and get methods

Brian Burkhalter brian.burkhalter at oracle.com
Tue Oct 16 19:06:48 UTC 2018

> On Oct 16, 2018, at 12:01 PM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 16/10/2018 18:15, Brian Burkhalter wrote:
>> :
>> With respect to methods 1 and 2, a question I have concerns the exception(s) which may be thrown. In the patch, an IndexOutOfBoundsException is thrown if there is any inconsistency in the supplied parameters. This is analogous to the absolute get and put methods which handle a single value [1, 2], but is not very precise. One alternative would be instead to specify these exceptions for parameter consistency:
>> * IllegalArgumentException if index < 0
>> * IndexOutOfBoundsException if {dst,src}.length, offset, and length do not meet the preconditions
>> * Buffer{Under,Over}flowException for {get,put} if index + length > capacity()
> I don't have time just now to go through in detail but just to say that the existing absolute methods throw IOOBE when index is negative. They also throw IOOBE when the index + #bytes is beyond the limit. So I think we should keep those consistent. Also , and you noted, Buffer{Under,Over}Exception are for the methods that get/put from the buffer position so I don't think you'll need them here.

OK so it sounds like the existing patch is headed in the right direction at least.

One thing I noticed in the non-direct relative bulk methods is that surprisingly System.arraycopy() is not used when hasArray() returns true.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20181016/4c169cfe/attachment.html>

More information about the nio-dev mailing list