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

@ -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) {