< prev index next >
src/java.base/share/classes/java/lang/ArrayIndexOutOfBoundsException.java
Print this page
rev 49800 : 8201593: Print array length in ArrayIndexOutOfBoundsException.
@@ -62,6 +62,22 @@
* @param index the illegal index.
*/
public ArrayIndexOutOfBoundsException(int index) {
super("Array index out of range: " + index);
}
+
+ /**
+ * Constructs a new {@code ArrayIndexOutOfBoundsException} class with an
+ * argument indicating the illegal index and another indicating the length
+ * of the accessed array.
+ *
+ * <p>The index and the length are included in this exception's detail message.
+ * The exact presentation format of the detail message is unspecified.
+ * This is called from within the VM.
+ *
+ * @param index the illegal index.
+ * @param length the length of the accessed array.
+ */
+ private ArrayIndexOutOfBoundsException(int index, int length) {
+ super("trying to access index " + index + " of an array with length " + length);
+ }
}
< prev index next >