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

@ -290,7 +290,7 @@ class Direct$Type$Buffer$RW$$BO$
public $Type$Buffer get($type$[] dst, int offset, int length) {
#if[rw]
if (((long)length << $LG_BYTES_PER_VALUE$) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
checkBounds(offset, length, dst.length);
Objects.checkFromIndexSize(offset, length, dst.length);
int pos = position();
int lim = limit();
assert (pos <= lim);
@ -439,7 +439,7 @@ class Direct$Type$Buffer$RW$$BO$
public $Type$Buffer put($type$[] src, int offset, int length) {
#if[rw]
if (((long)length << $LG_BYTES_PER_VALUE$) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
checkBounds(offset, length, src.length);
Objects.checkFromIndexSize(offset, length, src.length);
int pos = position();
int lim = limit();
assert (pos <= lim);
@ -545,8 +545,7 @@ class Direct$Type$Buffer$RW$$BO$
#if[char]
public String toString(int start, int end) {
if ((end > limit()) || (start > end))
throw new IndexOutOfBoundsException();
Objects.checkFromToIndex(start, end, limit());
try {
int len = end - start;
char[] ca = new char[len];
@ -571,8 +570,7 @@ class Direct$Type$Buffer$RW$$BO$
pos = (pos <= lim ? pos : lim);
int len = lim - pos;
if ((start < 0) || (end > len) || (start > end))
throw new IndexOutOfBoundsException();
Objects.checkFromToIndex(start, end, len);
return new DirectCharBuffer$RW$$BO$(this,
-1,
pos + start,