mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8219876: (bf) Improve IndexOutOfBoundsException messages in $Type$Buffer classes
Reviewed-by: alanb, rriggs
This commit is contained in:
parent
5c5089b0a2
commit
7211761cab
6 changed files with 14 additions and 27 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue