mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8268698: Use Objects.check{Index,FromToIndex,FromIndexSize} for java.base
Reviewed-by: mchung, rriggs
This commit is contained in:
parent
a4e5f08fef
commit
afe957cd97
40 changed files with 186 additions and 284 deletions
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -230,9 +231,7 @@ public class Deflater {
|
|||
* @see Deflater#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;
|
||||
|
@ -297,9 +296,7 @@ public class Deflater {
|
|||
* @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);
|
||||
|
@ -556,9 +553,7 @@ public class Deflater {
|
|||
* @since 1.7
|
||||
*/
|
||||
public int deflate(byte[] output, int off, int len, int flush) {
|
||||
if (off < 0 || len < 0 || off > output.length - len) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
Preconditions.checkFromIndexSize(len, off, output.length, Preconditions.AIOOBE_FORMATTER);
|
||||
if (flush != NO_FLUSH && flush != SYNC_FLUSH && flush != FULL_FLUSH) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue