diff -r c0fccca69aff -r deb99f13c6cd src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template --- 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,