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

Brian Burkhalter brian.burkhalter at oracle.com
Mon Feb 11 17:32:39 UTC 2019

Hi Alan, Chris,

Thanks for the comments.

> On Feb 11, 2019, at 2:15 AM, Chris Hegarty <chris.hegarty at oracle.com> wrote:
>> On 10 Feb 2019, at 16:17, Alan Bateman <Alan.Bateman at oracle.com <mailto:Alan.Bateman at oracle.com>> wrote:
>>> […]
> A very minor comment regarding the `index` param description:
>   "The index *in this buffer from/at which the first* $type$ will be
>    read/written”

I agree that that is better; will update accordingly.

>> The signatures of the first 4 methods look right, the javadoc looks good too. I'm just mulling over the case where there are fewer than `length` bytes between the index and the limit. The relative bulk get/put will throw BufferUnderflowException or BufferOverflowException for these cases. I realize we touched on this in an earlier iteration but looking at it now then I think we need to re-examine that point to decide on the exceptions.
> AFAIK current index / precondition checks regarding a buffer's space
> availability result in Buffer[Under|Over]flowException. Array based
> precondition checks result in IndexOutOfBoundsException. Might be best
> to keep the current model.

It really is kind of a toss up, no? One advantage of using Buffer*flowException would be differentiating whether ‘this’ or the parameter {array, buffer} would have an out of bounds access.

>> put(index, src, offset, length) need discussion and okay to move to a separate issue if you want. The absolute version of put(src) is put(index, src), going further would be put(index, src, srcIndex, int length). The rename of "offset" to "srcIndex" is deliberate as it would be too easy to assume the offset is from the buffer's position. Another thing to mention is that put(src) throws IAE when you the source is the same buffer. If you are allow the source to be the same buffer in the absolute version then it will need to specify how overlapping regions are handled.
> Wow, this one could be tricky if both this buffer and src are allowed
> to be the same. Straight forward if not.  I can see the use-case of
> shuffling around some data in a single buffer, which will work fine once
> there is no overlapping region. I think this is a reasonable use-case,
> but will have to see how allowing such will impact on the API.

In the case of the relative method, the state of ‘this’ and the parameter buffer are both being modified which would cause problems if they were the same buffer. That is not the case here. I wonder whether the same buffer should be allowed without restriction thereby leaving it to the user to ensure that there is no problem? Or would that be too much of a free for all?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190211/13ed9850/attachment.html>

More information about the nio-dev mailing list