--- a/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template Fri Mar 15 16:00:18 2019 -0400
+++ b/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template Fri Mar 15 16:24:07 2019 -0700
@@ -173,7 +173,7 @@
#end[streamableType]
public $Type$Buffer get($type$[] dst, int offset, int length) {
- checkBounds(offset, length, dst.length);
+ Objects.checkFromIndexSize(offset, length, dst.length);
int pos = position();
if (length > limit() - pos)
throw new BufferUnderflowException();
@@ -219,7 +219,7 @@
public $Type$Buffer put($type$[] src, int offset, int length) {
#if[rw]
- checkBounds(offset, length, src.length);
+ Objects.checkFromIndexSize(offset, length, src.length);
int pos = position();
if (length > limit() - pos)
throw new BufferOverflowException();
@@ -277,7 +277,7 @@
public $Type$Buffer put(String src, int start, int end) {
int length = end - start;
- checkBounds(start, length, src.length());
+ Objects.checkFromIndexSize(start, length, src.length());
if (isReadOnly())
throw new ReadOnlyBufferException();
int pos = position();
@@ -659,11 +659,8 @@
// --- Methods to support CharSequence ---
public CharBuffer subSequence(int start, int end) {
- if ((start < 0)
- || (end > length())
- || (start > end))
- throw new IndexOutOfBoundsException();
int pos = position();
+ Objects.checkFromToIndex(start, end, limit() - pos);
return new HeapCharBuffer$RW$(hb,
-1,
pos + start,