< prev index next >

src/java.base/share/classes/jdk/internal/util/Preconditions.java

Print this page
rev 50037 : 8202745: Remove hyphens from "out-of-bounds".

*** 183,238 **** } // Switch to default if fewer or more arguments than required are supplied switch ((args.size() != argSize) ? "" : checkKind) { case "checkIndex": ! return String.format("Index %d out-of-bounds for length %d", args.get(0), args.get(1)); case "checkFromToIndex": ! return String.format("Range [%d, %d) out-of-bounds for length %d", args.get(0), args.get(1), args.get(2)); case "checkFromIndexSize": ! return String.format("Range [%d, %<d + %d) out-of-bounds for length %d", args.get(0), args.get(1), args.get(2)); default: return String.format("Range check failed: %s %s", checkKind, args); } } /** * Checks if the {@code index} is within the bounds of the range from * {@code 0} (inclusive) to {@code length} (exclusive). * ! * <p>The {@code index} is defined to be out-of-bounds if any of the * following inequalities is true: * <ul> * <li>{@code index < 0}</li> * <li>{@code index >= length}</li> * <li>{@code length < 0}, which is implied from the former inequalities</li> * </ul> * ! * <p>If the {@code index} is out-of-bounds, then a runtime exception is * thrown that is the result of applying the following arguments to the * exception formatter: the name of this method, {@code checkIndex}; * and an unmodifiable list integers whose values are, in order, the * out-of-bounds arguments {@code index} and {@code length}. * * @param <X> the type of runtime exception to throw if the arguments are ! * out-of-bounds * @param index the index * @param length the upper-bound (exclusive) of the range * @param oobef the exception formatter that when applied with this * method name and out-of-bounds arguments returns a runtime * exception. If {@code null} or returns {@code null} then, it is as * if an exception formatter produced from an invocation of * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used * instead (though it may be more efficient). * Exceptions thrown by the formatter are relayed to the caller. * @return {@code index} if it is within bounds of the range ! * @throws X if the {@code index} is out-of-bounds and the exception * formatter is non-{@code null} ! * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds * and the exception formatter is {@code null} * @since 9 * * @implNote * This method is made intrinsic in optimizing compilers to guide them to --- 183,238 ---- } // Switch to default if fewer or more arguments than required are supplied switch ((args.size() != argSize) ? "" : checkKind) { case "checkIndex": ! return String.format("Index %d out of bounds for length %d", args.get(0), args.get(1)); case "checkFromToIndex": ! return String.format("Range [%d, %d) out of bounds for length %d", args.get(0), args.get(1), args.get(2)); case "checkFromIndexSize": ! return String.format("Range [%d, %<d + %d) out of bounds for length %d", args.get(0), args.get(1), args.get(2)); default: return String.format("Range check failed: %s %s", checkKind, args); } } /** * Checks if the {@code index} is within the bounds of the range from * {@code 0} (inclusive) to {@code length} (exclusive). * ! * <p>The {@code index} is defined to be out of bounds if any of the * following inequalities is true: * <ul> * <li>{@code index < 0}</li> * <li>{@code index >= length}</li> * <li>{@code length < 0}, which is implied from the former inequalities</li> * </ul> * ! * <p>If the {@code index} is out of bounds, then a runtime exception is * thrown that is the result of applying the following arguments to the * exception formatter: the name of this method, {@code checkIndex}; * and an unmodifiable list integers whose values are, in order, the * out-of-bounds arguments {@code index} and {@code length}. * * @param <X> the type of runtime exception to throw if the arguments are ! * out of bounds * @param index the index * @param length the upper-bound (exclusive) of the range * @param oobef the exception formatter that when applied with this * method name and out-of-bounds arguments returns a runtime * exception. If {@code null} or returns {@code null} then, it is as * if an exception formatter produced from an invocation of * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used * instead (though it may be more efficient). * Exceptions thrown by the formatter are relayed to the caller. * @return {@code index} if it is within bounds of the range ! * @throws X if the {@code index} is out of bounds and the exception * formatter is non-{@code null} ! * @throws IndexOutOfBoundsException if the {@code index} is out of bounds * and the exception formatter is {@code null} * @since 9 * * @implNote * This method is made intrinsic in optimizing compilers to guide them to
*** 252,278 **** /** * Checks if the sub-range from {@code fromIndex} (inclusive) to * {@code toIndex} (exclusive) is within the bounds of range from {@code 0} * (inclusive) to {@code length} (exclusive). * ! * <p>The sub-range is defined to be out-of-bounds if any of the following * inequalities is true: * <ul> * <li>{@code fromIndex < 0}</li> * <li>{@code fromIndex > toIndex}</li> * <li>{@code toIndex > length}</li> * <li>{@code length < 0}, which is implied from the former inequalities</li> * </ul> * ! * <p>If the sub-range is out-of-bounds, then a runtime exception is * thrown that is the result of applying the following arguments to the * exception formatter: the name of this method, {@code checkFromToIndex}; * and an unmodifiable list integers whose values are, in order, the * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}. * * @param <X> the type of runtime exception to throw if the arguments are ! * out-of-bounds * @param fromIndex the lower-bound (inclusive) of the sub-range * @param toIndex the upper-bound (exclusive) of the sub-range * @param length the upper-bound (exclusive) the range * @param oobef the exception formatter that when applied with this * method name and out-of-bounds arguments returns a runtime --- 252,278 ---- /** * Checks if the sub-range from {@code fromIndex} (inclusive) to * {@code toIndex} (exclusive) is within the bounds of range from {@code 0} * (inclusive) to {@code length} (exclusive). * ! * <p>The sub-range is defined to be out of bounds if any of the following * inequalities is true: * <ul> * <li>{@code fromIndex < 0}</li> * <li>{@code fromIndex > toIndex}</li> * <li>{@code toIndex > length}</li> * <li>{@code length < 0}, which is implied from the former inequalities</li> * </ul> * ! * <p>If the sub-range is out of bounds, then a runtime exception is * thrown that is the result of applying the following arguments to the * exception formatter: the name of this method, {@code checkFromToIndex}; * and an unmodifiable list integers whose values are, in order, the * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}. * * @param <X> the type of runtime exception to throw if the arguments are ! * out of bounds * @param fromIndex the lower-bound (inclusive) of the sub-range * @param toIndex the upper-bound (exclusive) of the sub-range * @param length the upper-bound (exclusive) the range * @param oobef the exception formatter that when applied with this * method name and out-of-bounds arguments returns a runtime
*** 280,292 **** * if an exception formatter produced from an invocation of * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used * instead (though it may be more efficient). * Exceptions thrown by the formatter are relayed to the caller. * @return {@code fromIndex} if the sub-range within bounds of the range ! * @throws X if the sub-range is out-of-bounds and the exception factory * function is non-{@code null} ! * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and * the exception factory function is {@code null} * @since 9 */ public static <X extends RuntimeException> int checkFromToIndex(int fromIndex, int toIndex, int length, --- 280,292 ---- * if an exception formatter produced from an invocation of * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used * instead (though it may be more efficient). * Exceptions thrown by the formatter are relayed to the caller. * @return {@code fromIndex} if the sub-range within bounds of the range ! * @throws X if the sub-range is out of bounds and the exception factory * function is non-{@code null} ! * @throws IndexOutOfBoundsException if the sub-range is out of bounds and * the exception factory function is {@code null} * @since 9 */ public static <X extends RuntimeException> int checkFromToIndex(int fromIndex, int toIndex, int length,
*** 299,326 **** /** * Checks if the sub-range from {@code fromIndex} (inclusive) to * {@code fromIndex + size} (exclusive) is within the bounds of range from * {@code 0} (inclusive) to {@code length} (exclusive). * ! * <p>The sub-range is defined to be out-of-bounds if any of the following * inequalities is true: * <ul> * <li>{@code fromIndex < 0}</li> * <li>{@code size < 0}</li> * <li>{@code fromIndex + size > length}, taking into account integer overflow</li> * <li>{@code length < 0}, which is implied from the former inequalities</li> * </ul> * ! * <p>If the sub-range is out-of-bounds, then a runtime exception is * thrown that is the result of applying the following arguments to the * exception formatter: the name of this method, {@code checkFromIndexSize}; * and an unmodifiable list integers whose values are, in order, the * out-of-bounds arguments {@code fromIndex}, {@code size}, and * {@code length}. * * @param <X> the type of runtime exception to throw if the arguments are ! * out-of-bounds * @param fromIndex the lower-bound (inclusive) of the sub-interval * @param size the size of the sub-range * @param length the upper-bound (exclusive) of the range * @param oobef the exception formatter that when applied with this * method name and out-of-bounds arguments returns a runtime --- 299,326 ---- /** * Checks if the sub-range from {@code fromIndex} (inclusive) to * {@code fromIndex + size} (exclusive) is within the bounds of range from * {@code 0} (inclusive) to {@code length} (exclusive). * ! * <p>The sub-range is defined to be out of bounds if any of the following * inequalities is true: * <ul> * <li>{@code fromIndex < 0}</li> * <li>{@code size < 0}</li> * <li>{@code fromIndex + size > length}, taking into account integer overflow</li> * <li>{@code length < 0}, which is implied from the former inequalities</li> * </ul> * ! * <p>If the sub-range is out of bounds, then a runtime exception is * thrown that is the result of applying the following arguments to the * exception formatter: the name of this method, {@code checkFromIndexSize}; * and an unmodifiable list integers whose values are, in order, the * out-of-bounds arguments {@code fromIndex}, {@code size}, and * {@code length}. * * @param <X> the type of runtime exception to throw if the arguments are ! * out of bounds * @param fromIndex the lower-bound (inclusive) of the sub-interval * @param size the size of the sub-range * @param length the upper-bound (exclusive) of the range * @param oobef the exception formatter that when applied with this * method name and out-of-bounds arguments returns a runtime
*** 328,340 **** * if an exception formatter produced from an invocation of * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used * instead (though it may be more efficient). * Exceptions thrown by the formatter are relayed to the caller. * @return {@code fromIndex} if the sub-range within bounds of the range ! * @throws X if the sub-range is out-of-bounds and the exception factory * function is non-{@code null} ! * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and * the exception factory function is {@code null} * @since 9 */ public static <X extends RuntimeException> int checkFromIndexSize(int fromIndex, int size, int length, --- 328,340 ---- * if an exception formatter produced from an invocation of * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used * instead (though it may be more efficient). * Exceptions thrown by the formatter are relayed to the caller. * @return {@code fromIndex} if the sub-range within bounds of the range ! * @throws X if the sub-range is out of bounds and the exception factory * function is non-{@code null} ! * @throws IndexOutOfBoundsException if the sub-range is out of bounds and * the exception factory function is {@code null} * @since 9 */ public static <X extends RuntimeException> int checkFromIndexSize(int fromIndex, int size, int length,
< prev index next >