5029431: (bf) Add absolute bulk put and get methods
Chris Hegarty
chris.hegarty at oracle.com
Mon Feb 11 10:15:24 UTC 2019
Brian,
Overall I think this is very good, and I'm happy to see it moving
forward.
> On 10 Feb 2019, at 16:17, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>
> On 08/02/2019 23:08, Brian Burkhalter wrote:
>> Continuing the thread [1] from October, 2018 regarding [2].
>>
>> The webrev [3] includes mainly the template files, not source nor test files generated therefrom. The following methods are added to the $Type$Buffer classes where $Type$ is in {Byte, Char, Double, Float, Int, Long, Short} and, respectively, $type$ is in {byte, char, double, float, int, long, short}:
>>
>> public $Type$Buffer get(int index, $type$[] dst, int offset, int length) {}
>> public $Type$Buffer get(int index, $type$[] dst) {}
>> public $Type$Buffer put(int index, $type$[] src, int offset, int length) {}
>> public $Type$Buffer put(int index, $type$[] src) {}
A very minor comment regarding the `index` param description:
"The index *in this buffer from/at which the first* $type$ will be
read/written"
>> public $Type$Buffer put(int index, $Type$Buffer src, int offset, int length) {}
>>
>> In addition to the changes implied by the foregoing, there is a javadoc fix at line 843 / 927, and “@throws NullPointerException” is removed at line 437 as it is redundant with the package documentation.
>>
>> (I know there are some commented out print statements; they’ll be excised later.)
>>
> 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.
> 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.
-Chris.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190211/0b47382d/attachment.html>
More information about the nio-dev
mailing list