8268698: Use Objects.check{Index,FromToIndex,FromIndexSize} for java.base

Reviewed-by: mchung, rriggs
This commit is contained in:
Yi Yang 2021-07-13 02:23:16 +00:00
parent a4e5f08fef
commit afe957cd97
40 changed files with 186 additions and 284 deletions

View file

@ -32,6 +32,7 @@ import java.nio.ReadOnlyBufferException;
import java.util.Objects;
import jdk.internal.ref.CleanerFactory;
import jdk.internal.util.Preconditions;
import sun.nio.ch.DirectBuffer;
/**
@ -151,9 +152,7 @@ public class Inflater {
* @see Inflater#needsInput
*/
public void setInput(byte[] input, int off, int len) {
if (off < 0 || len < 0 || off > input.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
Preconditions.checkFromIndexSize(len, off, input.length, Preconditions.AIOOBE_FORMATTER);
synchronized (zsRef) {
this.input = null;
this.inputArray = input;
@ -218,9 +217,7 @@ public class Inflater {
* @see Inflater#getAdler
*/
public void setDictionary(byte[] dictionary, int off, int len) {
if (off < 0 || len < 0 || off > dictionary.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
Preconditions.checkFromIndexSize(len, off, dictionary.length, Preconditions.AIOOBE_FORMATTER);
synchronized (zsRef) {
ensureOpen();
setDictionary(zsRef.address(), dictionary, off, len);
@ -363,9 +360,7 @@ public class Inflater {
public int inflate(byte[] output, int off, int len)
throws DataFormatException
{
if (off < 0 || len < 0 || off > output.length - len) {
throw new ArrayIndexOutOfBoundsException();
}
Preconditions.checkFromIndexSize(len, off, output.length, Preconditions.AIOOBE_FORMATTER);
synchronized (zsRef) {
ensureOpen();
ByteBuffer input = this.input;