8220614: (bf) Buffer absolute slice methods should use Objects.checkFromIndexSize()
Reviewed-by: alanb, igerasim, rriggs
--- a/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template Thu Mar 14 09:35:45 2019 -0700
+++ b/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template Thu Mar 14 09:43:18 2019 -0700
@@ -87,8 +87,7 @@
@Override
public $Type$Buffer slice(int index, int length) {
- Objects.checkIndex(index, limit() + 1);
- Objects.checkIndex(length, limit() - index + 1);
+ Objects.checkFromIndexSize(index, length, limit());
return new ByteBufferAs$Type$Buffer$RW$$BO$(bb,
-1,
0,
--- a/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template Thu Mar 14 09:35:45 2019 -0700
+++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template Thu Mar 14 09:43:18 2019 -0700
@@ -220,8 +220,7 @@
@Override
public $Type$Buffer slice(int index, int length) {
- Objects.checkIndex(index, limit() + 1);
- Objects.checkIndex(length, limit() - index + 1);
+ Objects.checkFromIndexSize(index, length, limit());
return new Direct$Type$Buffer$RW$$BO$(this,
-1,
0,
--- a/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template Thu Mar 14 09:35:45 2019 -0700
+++ b/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template Thu Mar 14 09:43:18 2019 -0700
@@ -115,8 +115,7 @@
@Override
public $Type$Buffer slice(int index, int length) {
- Objects.checkIndex(index, limit() + 1);
- Objects.checkIndex(length, limit() - index + 1);
+ Objects.checkFromIndexSize(index, length, limit());
return new Heap$Type$Buffer$RW$(hb,
-1,
0,
--- a/src/java.base/share/classes/java/nio/StringCharBuffer.java Thu Mar 14 09:35:45 2019 -0700
+++ b/src/java.base/share/classes/java/nio/StringCharBuffer.java Thu Mar 14 09:43:18 2019 -0700
@@ -54,8 +54,7 @@
@Override
public CharBuffer slice(int index, int length) {
- Objects.checkIndex(index, limit() + 1);
- Objects.checkIndex(length, limit() - index + 1);
+ Objects.checkFromIndexSize(index, length, limit());
return new StringCharBuffer(str,
-1,
0,