5029431: (bf) Add absolute bulk put and get methods
Alan Bateman
Alan.Bateman at oracle.com
Sun Feb 10 16:17:30 UTC 2019
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) {}
> 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.
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.
-Alan
More information about the nio-dev
mailing list