mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +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.util.Spliterator;
|
|||
import java.util.stream.IntStream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import jdk.internal.util.ArraysSupport;
|
||||
import jdk.internal.util.Preconditions;
|
||||
|
||||
import static java.lang.String.COMPACT_STRINGS;
|
||||
import static java.lang.String.UTF16;
|
||||
|
@ -409,9 +410,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
*/
|
||||
public int codePointBefore(int index) {
|
||||
int i = index - 1;
|
||||
if (i < 0 || i >= count) {
|
||||
throw new StringIndexOutOfBoundsException(index);
|
||||
}
|
||||
checkIndex(i, count);
|
||||
if (isLatin1()) {
|
||||
return value[i] & 0xff;
|
||||
}
|
||||
|
@ -505,9 +504,9 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
*/
|
||||
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
|
||||
{
|
||||
checkRangeSIOOBE(srcBegin, srcEnd, count); // compatible to old version
|
||||
Preconditions.checkFromToIndex(srcBegin, srcEnd, count, Preconditions.SIOOBE_FORMATTER); // compatible to old version
|
||||
int n = srcEnd - srcBegin;
|
||||
checkRange(dstBegin, dstBegin + n, dst.length);
|
||||
Preconditions.checkFromToIndex(dstBegin, dstBegin + n, dst.length, Preconditions.IOOBE_FORMATTER);
|
||||
if (isLatin1()) {
|
||||
StringLatin1.getChars(value, srcBegin, srcEnd, dst, dstBegin);
|
||||
} else {
|
||||
|
@ -677,7 +676,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
if (s == null) {
|
||||
s = "null";
|
||||
}
|
||||
checkRange(start, end, s.length());
|
||||
Preconditions.checkFromToIndex(start, end, s.length(), Preconditions.IOOBE_FORMATTER);
|
||||
int len = end - start;
|
||||
ensureCapacityInternal(count + len);
|
||||
if (s instanceof String) {
|
||||
|
@ -736,7 +735,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
*/
|
||||
public AbstractStringBuilder append(char[] str, int offset, int len) {
|
||||
int end = offset + len;
|
||||
checkRange(offset, end, str.length);
|
||||
Preconditions.checkFromToIndex(offset, end, str.length, Preconditions.IOOBE_FORMATTER);
|
||||
ensureCapacityInternal(count + len);
|
||||
appendChars(str, offset, end);
|
||||
return this;
|
||||
|
@ -914,7 +913,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
if (end > count) {
|
||||
end = count;
|
||||
}
|
||||
checkRangeSIOOBE(start, end, count);
|
||||
Preconditions.checkFromToIndex(start, end, count, Preconditions.SIOOBE_FORMATTER);
|
||||
int len = end - start;
|
||||
if (len > 0) {
|
||||
shift(end, -len);
|
||||
|
@ -997,7 +996,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
if (end > count) {
|
||||
end = count;
|
||||
}
|
||||
checkRangeSIOOBE(start, end, count);
|
||||
Preconditions.checkFromToIndex(start, end, count, Preconditions.SIOOBE_FORMATTER);
|
||||
int len = str.length();
|
||||
int newCount = count + len - (end - start);
|
||||
ensureCapacityInternal(newCount);
|
||||
|
@ -1067,7 +1066,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
* greater than {@code end}.
|
||||
*/
|
||||
public String substring(int start, int end) {
|
||||
checkRangeSIOOBE(start, end, count);
|
||||
Preconditions.checkFromToIndex(start, end, count, Preconditions.SIOOBE_FORMATTER);
|
||||
if (isLatin1()) {
|
||||
return StringLatin1.newString(value, start, end - start);
|
||||
}
|
||||
|
@ -1104,7 +1103,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
int len)
|
||||
{
|
||||
checkOffset(index, count);
|
||||
checkRangeSIOOBE(offset, offset + len, str.length);
|
||||
Preconditions.checkFromToIndex(offset, offset + len, str.length, Preconditions.SIOOBE_FORMATTER);
|
||||
ensureCapacityInternal(count + len);
|
||||
shift(index, len);
|
||||
count += len;
|
||||
|
@ -1292,7 +1291,7 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
s = "null";
|
||||
}
|
||||
checkOffset(dstOffset, count);
|
||||
checkRange(start, end, s.length());
|
||||
Preconditions.checkFromToIndex(start, end, s.length(), Preconditions.IOOBE_FORMATTER);
|
||||
int len = end - start;
|
||||
ensureCapacityInternal(count + len);
|
||||
shift(dstOffset, len);
|
||||
|
@ -1795,20 +1794,4 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
|||
}
|
||||
count += end - off;
|
||||
}
|
||||
|
||||
/* IndexOutOfBoundsException, if out of bounds */
|
||||
private static void checkRange(int start, int end, int len) {
|
||||
if (start < 0 || start > end || end > len) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"start " + start + ", end " + end + ", length " + len);
|
||||
}
|
||||
}
|
||||
|
||||
/* StringIndexOutOfBoundsException, if out of bounds */
|
||||
private static void checkRangeSIOOBE(int start, int end, int len) {
|
||||
if (start < 0 || start > end || end > len) {
|
||||
throw new StringIndexOutOfBoundsException(
|
||||
"start " + start + ", end " + end + ", length " + len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST;
|
||||
|
@ -9249,10 +9250,7 @@ class Character implements java.io.Serializable, Comparable<Character>, Constabl
|
|||
* @since 1.5
|
||||
*/
|
||||
public static int codePointCount(CharSequence seq, int beginIndex, int endIndex) {
|
||||
int length = seq.length();
|
||||
if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
Objects.checkFromToIndex(beginIndex, endIndex, seq.length());
|
||||
int n = endIndex - beginIndex;
|
||||
for (int i = beginIndex; i < endIndex; ) {
|
||||
if (isHighSurrogate(seq.charAt(i++)) && i < endIndex &&
|
||||
|
@ -9284,9 +9282,7 @@ class Character implements java.io.Serializable, Comparable<Character>, Constabl
|
|||
* @since 1.5
|
||||
*/
|
||||
public static int codePointCount(char[] a, int offset, int count) {
|
||||
if (count > a.length - offset || offset < 0 || count < 0) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
Objects.checkFromIndexSize(count, offset, a.length);
|
||||
return codePointCountImpl(a, offset, count);
|
||||
}
|
||||
|
||||
|
|
|
@ -709,10 +709,8 @@ public final class Integer extends Number
|
|||
public static int parseInt(CharSequence s, int beginIndex, int endIndex, int radix)
|
||||
throws NumberFormatException {
|
||||
Objects.requireNonNull(s);
|
||||
Objects.checkFromToIndex(beginIndex, endIndex, s.length());
|
||||
|
||||
if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
if (radix < Character.MIN_RADIX) {
|
||||
throw new NumberFormatException("radix " + radix +
|
||||
" less than Character.MIN_RADIX");
|
||||
|
@ -892,10 +890,8 @@ public final class Integer extends Number
|
|||
public static int parseUnsignedInt(CharSequence s, int beginIndex, int endIndex, int radix)
|
||||
throws NumberFormatException {
|
||||
Objects.requireNonNull(s);
|
||||
Objects.checkFromToIndex(beginIndex, endIndex, s.length());
|
||||
|
||||
if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
int start = beginIndex, len = endIndex - beginIndex;
|
||||
|
||||
if (len > 0) {
|
||||
|
|
|
@ -752,10 +752,8 @@ public final class Long extends Number
|
|||
public static long parseLong(CharSequence s, int beginIndex, int endIndex, int radix)
|
||||
throws NumberFormatException {
|
||||
Objects.requireNonNull(s);
|
||||
Objects.checkFromToIndex(beginIndex, endIndex, s.length());
|
||||
|
||||
if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
if (radix < Character.MIN_RADIX) {
|
||||
throw new NumberFormatException("radix " + radix +
|
||||
" less than Character.MIN_RADIX");
|
||||
|
@ -998,10 +996,8 @@ public final class Long extends Number
|
|||
public static long parseUnsignedLong(CharSequence s, int beginIndex, int endIndex, int radix)
|
||||
throws NumberFormatException {
|
||||
Objects.requireNonNull(s);
|
||||
Objects.checkFromToIndex(beginIndex, endIndex, s.length());
|
||||
|
||||
if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
int start = beginIndex, len = endIndex - beginIndex;
|
||||
|
||||
if (len > 0) {
|
||||
|
|
|
@ -51,6 +51,7 @@ import java.util.stream.IntStream;
|
|||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import jdk.internal.util.Preconditions;
|
||||
import jdk.internal.vm.annotation.ForceInline;
|
||||
import jdk.internal.vm.annotation.IntrinsicCandidate;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
@ -1571,9 +1572,7 @@ public final class String
|
|||
*/
|
||||
public int codePointBefore(int index) {
|
||||
int i = index - 1;
|
||||
if (i < 0 || i >= length()) {
|
||||
throw new StringIndexOutOfBoundsException(index);
|
||||
}
|
||||
checkIndex(i, length());
|
||||
if (isLatin1()) {
|
||||
return (value[i] & 0xff);
|
||||
}
|
||||
|
@ -1602,10 +1601,7 @@ public final class String
|
|||
* @since 1.5
|
||||
*/
|
||||
public int codePointCount(int beginIndex, int endIndex) {
|
||||
if (beginIndex < 0 || beginIndex > endIndex ||
|
||||
endIndex > length()) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
Objects.checkFromToIndex(beginIndex, endIndex, length());
|
||||
if (isLatin1()) {
|
||||
return endIndex - beginIndex;
|
||||
}
|
||||
|
@ -4556,10 +4552,7 @@ public final class String
|
|||
* negative or greater than or equal to {@code length}.
|
||||
*/
|
||||
static void checkIndex(int index, int length) {
|
||||
if (index < 0 || index >= length) {
|
||||
throw new StringIndexOutOfBoundsException("index " + index +
|
||||
", length " + length);
|
||||
}
|
||||
Preconditions.checkIndex(index, length, Preconditions.SIOOBE_FORMATTER);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4567,10 +4560,7 @@ public final class String
|
|||
* is negative or greater than {@code length}.
|
||||
*/
|
||||
static void checkOffset(int offset, int length) {
|
||||
if (offset < 0 || offset > length) {
|
||||
throw new StringIndexOutOfBoundsException("offset " + offset +
|
||||
", length " + length);
|
||||
}
|
||||
Preconditions.checkFromToIndex(offset, length, length, Preconditions.SIOOBE_FORMATTER);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4582,10 +4572,7 @@ public final class String
|
|||
* or {@code offset} is greater than {@code length - count}
|
||||
*/
|
||||
static void checkBoundsOffCount(int offset, int count, int length) {
|
||||
if (offset < 0 || count < 0 || offset > length - count) {
|
||||
throw new StringIndexOutOfBoundsException(
|
||||
"offset " + offset + ", count " + count + ", length " + length);
|
||||
}
|
||||
Preconditions.checkFromIndexSize(offset, count, length, Preconditions.SIOOBE_FORMATTER);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4597,10 +4584,7 @@ public final class String
|
|||
* {@code end}, or {@code end} is greater than {@code length}.
|
||||
*/
|
||||
static void checkBoundsBeginEnd(int begin, int end, int length) {
|
||||
if (begin < 0 || begin > end || end > length) {
|
||||
throw new StringIndexOutOfBoundsException(
|
||||
"begin " + begin + ", end " + end + ", length " + length);
|
||||
}
|
||||
Preconditions.checkFromToIndex(begin, end, length, Preconditions.SIOOBE_FORMATTER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,14 +39,13 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
|
|||
|
||||
import static java.lang.String.LATIN1;
|
||||
import static java.lang.String.UTF16;
|
||||
import static java.lang.String.checkIndex;
|
||||
import static java.lang.String.checkOffset;
|
||||
|
||||
final class StringLatin1 {
|
||||
|
||||
public static char charAt(byte[] value, int index) {
|
||||
if (index < 0 || index >= value.length) {
|
||||
throw new StringIndexOutOfBoundsException(index);
|
||||
}
|
||||
checkIndex(index, value.length);
|
||||
return (char)(value[index] & 0xff);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.security.AccessController;
|
|||
import java.security.PrivilegedAction;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
|
@ -113,8 +114,9 @@ final class MethodTypeDescImpl implements MethodTypeDesc {
|
|||
|
||||
@Override
|
||||
public MethodTypeDesc dropParameterTypes(int start, int end) {
|
||||
if (start < 0 || start >= argTypes.length || end < 0 || end > argTypes.length || start > end)
|
||||
throw new IndexOutOfBoundsException();
|
||||
Objects.checkIndex(start, argTypes.length);
|
||||
Objects.checkFromToIndex(start, end, argTypes.length);
|
||||
|
||||
ClassDesc[] newArgs = new ClassDesc[argTypes.length - (end - start)];
|
||||
System.arraycopy(argTypes, 0, newArgs, 0, start);
|
||||
System.arraycopy(argTypes, end, newArgs, start, argTypes.length - end);
|
||||
|
|
|
@ -28,9 +28,6 @@ package java.lang.invoke;
|
|||
import java.util.*;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
import static java.lang.invoke.MethodHandleStatics.rangeCheck1;
|
||||
import static java.lang.invoke.MethodHandleStatics.rangeCheck2;
|
||||
|
||||
/** Utility class for implementing ConstantGroup. */
|
||||
/*non-public*/
|
||||
abstract class AbstractConstantGroup implements ConstantGroup {
|
||||
|
@ -119,11 +116,11 @@ abstract class AbstractConstantGroup implements ConstantGroup {
|
|||
super(end - start);
|
||||
this.self = self;
|
||||
this.offset = start;
|
||||
rangeCheck2(start, end, size);
|
||||
Objects.checkFromToIndex(start, end, size);
|
||||
}
|
||||
|
||||
private int mapIndex(int index) {
|
||||
return rangeCheck1(index, size) + offset;
|
||||
return Objects.checkIndex(index, size) + offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,7 +140,7 @@ abstract class AbstractConstantGroup implements ConstantGroup {
|
|||
|
||||
@Override
|
||||
public ConstantGroup subGroup(int start, int end) {
|
||||
rangeCheck2(start, end, size);
|
||||
Objects.checkFromToIndex(start, end, size);
|
||||
return new SubGroup(self, offset + start, offset + end);
|
||||
}
|
||||
|
||||
|
@ -160,7 +157,7 @@ abstract class AbstractConstantGroup implements ConstantGroup {
|
|||
@Override
|
||||
public int copyConstants(int start, int end,
|
||||
Object[] buf, int pos) throws LinkageError {
|
||||
rangeCheck2(start, end, size);
|
||||
Objects.checkFromToIndex(start, end, size);
|
||||
return self.copyConstants(offset + start, offset + end,
|
||||
buf, pos);
|
||||
}
|
||||
|
@ -169,7 +166,7 @@ abstract class AbstractConstantGroup implements ConstantGroup {
|
|||
public int copyConstants(int start, int end,
|
||||
Object[] buf, int pos,
|
||||
Object ifNotPresent) {
|
||||
rangeCheck2(start, end, size);
|
||||
Objects.checkFromToIndex(start, end, size);
|
||||
return self.copyConstants(offset + start, offset + end,
|
||||
buf, pos, ifNotPresent);
|
||||
}
|
||||
|
@ -189,7 +186,7 @@ abstract class AbstractConstantGroup implements ConstantGroup {
|
|||
this.offset = start;
|
||||
this.resolving = resolving;
|
||||
this.ifNotPresent = ifNotPresent;
|
||||
rangeCheck2(start, end, self.size());
|
||||
Objects.checkFromToIndex(start, end, self.size());
|
||||
}
|
||||
AsList(ConstantGroup self, int start, int end) {
|
||||
this(self, start, end, true, null);
|
||||
|
@ -200,7 +197,7 @@ abstract class AbstractConstantGroup implements ConstantGroup {
|
|||
}
|
||||
|
||||
private int mapIndex(int index) {
|
||||
return rangeCheck1(index, size) + offset;
|
||||
return Objects.checkIndex(index, size) + offset;
|
||||
}
|
||||
|
||||
@Override public final int size() {
|
||||
|
@ -223,7 +220,7 @@ abstract class AbstractConstantGroup implements ConstantGroup {
|
|||
}
|
||||
|
||||
@Override public List<Object> subList(int start, int end) {
|
||||
rangeCheck2(start, end, size);
|
||||
Objects.checkFromToIndex(start, end, size);
|
||||
return new AsList(self, offset + start, offset + end,
|
||||
resolving, ifNotPresent);
|
||||
}
|
||||
|
|
|
@ -189,15 +189,4 @@ class MethodHandleStatics {
|
|||
if (obj != null || obj2 != null) message = message + ": " + obj + ", " + obj2;
|
||||
return message;
|
||||
}
|
||||
/*non-public*/
|
||||
static void rangeCheck2(int start, int end, int size) {
|
||||
if (0 > start || start > end || end > size)
|
||||
throw new IndexOutOfBoundsException(start+".."+end);
|
||||
}
|
||||
/*non-public*/
|
||||
static int rangeCheck1(int index, int size) {
|
||||
if (0 > index || index >= size)
|
||||
throw new IndexOutOfBoundsException(index);
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2179,15 +2179,6 @@ public abstract class VarHandle implements Constable {
|
|||
UNSAFE.fullFence();
|
||||
}
|
||||
|
||||
static final BiFunction<String, List<Number>, ArrayIndexOutOfBoundsException>
|
||||
AIOOBE_SUPPLIER = Preconditions.outOfBoundsExceptionFormatter(
|
||||
new Function<String, ArrayIndexOutOfBoundsException>() {
|
||||
@Override
|
||||
public ArrayIndexOutOfBoundsException apply(String s) {
|
||||
return new ArrayIndexOutOfBoundsException(s);
|
||||
}
|
||||
});
|
||||
|
||||
private static final long VFORM_OFFSET;
|
||||
|
||||
static {
|
||||
|
|
|
@ -830,7 +830,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.get$Type$Volatile(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
|
@ -842,7 +842,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
UNSAFE.put$Type$Volatile(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
||||
|
@ -855,7 +855,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.get$Type$Opaque(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
|
@ -867,7 +867,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
UNSAFE.put$Type$Opaque(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
||||
|
@ -880,7 +880,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.get$Type$Acquire(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase);
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase);
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
|
@ -892,7 +892,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
UNSAFE.put$Type$Release(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
#if[CAS]
|
||||
|
@ -906,7 +906,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.compareAndSet$Type$(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?handle.componentType.cast(expected):expected},
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
@ -920,7 +920,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.compareAndExchange$Type$(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?handle.componentType.cast(expected):expected},
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
@ -934,7 +934,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.compareAndExchange$Type$Acquire(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?handle.componentType.cast(expected):expected},
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
@ -948,7 +948,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.compareAndExchange$Type$Release(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?handle.componentType.cast(expected):expected},
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
@ -962,7 +962,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.weakCompareAndSet$Type$Plain(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?handle.componentType.cast(expected):expected},
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
@ -976,7 +976,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.weakCompareAndSet$Type$(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?handle.componentType.cast(expected):expected},
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
@ -990,7 +990,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.weakCompareAndSet$Type$Acquire(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?handle.componentType.cast(expected):expected},
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.weakCompareAndSet$Type$Release(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?handle.componentType.cast(expected):expected},
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
@ -1018,7 +1018,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.getAndSet$Type$(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
||||
|
@ -1031,7 +1031,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.getAndSet$Type$Acquire(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ final class VarHandle$Type$s {
|
|||
$type$[] array = ($type$[]) oarray;
|
||||
#end[Object]
|
||||
return UNSAFE.getAndSet$Type$Release(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
{#if[Object]?runtimeTypeCheck(handle, array, value):value});
|
||||
}
|
||||
#end[CAS]
|
||||
|
@ -1055,7 +1055,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndAdd$Type$(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1064,7 +1064,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndAdd$Type$Acquire(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1073,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndAdd$Type$Release(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
#end[AtomicAdd]
|
||||
|
@ -1084,7 +1084,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseOr$Type$(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1093,7 +1093,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseOr$Type$Release(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1102,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseOr$Type$Acquire(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1111,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseAnd$Type$(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1120,7 +1120,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseAnd$Type$Release(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1129,7 +1129,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseAnd$Type$Acquire(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1138,7 +1138,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseXor$Type$(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1147,7 +1147,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseXor$Type$Release(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1156,7 @@ final class VarHandle$Type$s {
|
|||
Array handle = (Array)ob;
|
||||
$type$[] array = ($type$[]) oarray;
|
||||
return UNSAFE.getAndBitwiseXor$Type$Acquire(array,
|
||||
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
|
||||
(((long) Preconditions.checkIndex(index, array.length, Preconditions.AIOOBE_FORMATTER)) << handle.ashift) + handle.abase,
|
||||
value);
|
||||
}
|
||||
#end[Bitwise]
|
||||
|
|
|
@ -109,12 +109,9 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
|
|||
return at.accessModeType(byte[].class, $type$.class, int.class);
|
||||
}
|
||||
|
||||
private static final BiFunction<String, List<Number>, ArrayIndexOutOfBoundsException>
|
||||
OOBEF = Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
|
||||
|
||||
@ForceInline
|
||||
static int index(byte[] ba, int index) {
|
||||
return Preconditions.checkIndex(index, ba.length - ALIGN, OOBEF);
|
||||
return Preconditions.checkIndex(index, ba.length - ALIGN, Preconditions.AIOOBE_FORMATTER);
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.io.OutputStream;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import sun.nio.cs.ISO_8859_1;
|
||||
|
||||
import jdk.internal.util.Preconditions;
|
||||
import jdk.internal.vm.annotation.IntrinsicCandidate;
|
||||
|
||||
/**
|
||||
|
@ -932,8 +932,7 @@ public class Base64 {
|
|||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
if (closed)
|
||||
throw new IOException("Stream is closed");
|
||||
if (off < 0 || len < 0 || len > b.length - off)
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
Preconditions.checkFromIndexSize(len, off, b.length, Preconditions.AIOOBE_FORMATTER);
|
||||
if (len == 0)
|
||||
return;
|
||||
if (leftover != 0) {
|
||||
|
|
|
@ -5178,9 +5178,7 @@ public class Collections {
|
|||
}
|
||||
|
||||
public E get(int index) {
|
||||
if (index < 0 || index >= n)
|
||||
throw new IndexOutOfBoundsException("Index: "+index+
|
||||
", Size: "+n);
|
||||
Objects.checkIndex(index, n);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ package java.util.zip;
|
|||
import java.lang.ref.Reference;
|
||||
import java.nio.ByteBuffer;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
import jdk.internal.util.Preconditions;
|
||||
import jdk.internal.vm.annotation.IntrinsicCandidate;
|
||||
|
||||
/**
|
||||
|
@ -74,9 +74,7 @@ public class Adler32 implements Checksum {
|
|||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (off < 0 || len < 0 || off > b.length - len) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
Preconditions.checkFromIndexSize(len, off, b.length, Preconditions.AIOOBE_FORMATTER);
|
||||
adler = updateBytes(adler, b, off, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.nio.ByteBuffer;
|
|||
import java.util.Objects;
|
||||
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
import jdk.internal.util.Preconditions;
|
||||
import jdk.internal.vm.annotation.IntrinsicCandidate;
|
||||
|
||||
/**
|
||||
|
@ -73,9 +74,7 @@ public class CRC32 implements Checksum {
|
|||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (off < 0 || len < 0 || off > b.length - len) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
Preconditions.checkFromIndexSize(len, off, b.length, Preconditions.AIOOBE_FORMATTER);
|
||||
crc = updateBytes(crc, b, off, len);
|
||||
}
|
||||
|
||||
|
@ -148,15 +147,8 @@ public class CRC32 implements Checksum {
|
|||
}
|
||||
|
||||
Objects.requireNonNull(b);
|
||||
|
||||
if (off < 0 || off >= b.length) {
|
||||
throw new ArrayIndexOutOfBoundsException(off);
|
||||
}
|
||||
|
||||
int endIndex = off + len - 1;
|
||||
if (endIndex < 0 || endIndex >= b.length) {
|
||||
throw new ArrayIndexOutOfBoundsException(endIndex);
|
||||
}
|
||||
Preconditions.checkIndex(off, b.length, Preconditions.AIOOBE_FORMATTER);
|
||||
Preconditions.checkIndex(off + len - 1, b.length, Preconditions.AIOOBE_FORMATTER);
|
||||
}
|
||||
|
||||
private static int updateByteBuffer(int alder, long addr,
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.ByteOrder;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.util.Preconditions;
|
||||
import jdk.internal.vm.annotation.IntrinsicCandidate;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
@ -148,9 +149,7 @@ public final class CRC32C implements Checksum {
|
|||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (off < 0 || len < 0 || off > b.length - len) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
Preconditions.checkFromIndexSize(len, off, b.length, Preconditions.AIOOBE_FORMATTER);
|
||||
crc = updateBytes(crc, b, off, (off + len));
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue