8219876: (bf) Improve IndexOutOfBoundsException messages in $Type$Buffer classes

Reviewed-by: alanb, rriggs
This commit is contained in:
Brian Burkhalter 2019-03-15 16:24:07 -07:00
parent 5c5089b0a2
commit 7211761cab
6 changed files with 14 additions and 27 deletions

View file

@ -772,7 +772,7 @@ public abstract class $Type$Buffer
* parameters do not hold
*/
public $Type$Buffer get($type$[] dst, int offset, int length) {
checkBounds(offset, length, dst.length);
Objects.checkFromIndexSize(offset, length, dst.length);
if (length > remaining())
throw new BufferUnderflowException();
int end = offset + length;
@ -996,7 +996,7 @@ public abstract class $Type$Buffer
* If this buffer is read-only
*/
public $Type$Buffer put($type$[] src, int offset, int length) {
checkBounds(offset, length, src.length);
Objects.checkFromIndexSize(offset, length, src.length);
if (length > remaining())
throw new BufferOverflowException();
int end = offset + length;
@ -1176,7 +1176,7 @@ public abstract class $Type$Buffer
* If this buffer is read-only
*/
public $Type$Buffer put(String src, int start, int end) {
checkBounds(start, end - start, src.length());
Objects.checkFromIndexSize(start, end - start, src.length());
if (isReadOnly())
throw new ReadOnlyBufferException();
if (end - start > remaining())