diff --git a/classpath/java/lang/ArrayIndexOutOfBoundsException.java b/classpath/java/lang/ArrayIndexOutOfBoundsException.java index 1478a62a2e..3ba5fccdec 100644 --- a/classpath/java/lang/ArrayIndexOutOfBoundsException.java +++ b/classpath/java/lang/ArrayIndexOutOfBoundsException.java @@ -23,6 +23,10 @@ public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException { this(null, cause); } + public ArrayIndexOutOfBoundsException(int idx) { + this("Array index out of range: " + idx); + } + public ArrayIndexOutOfBoundsException() { this(null, null); } diff --git a/classpath/java/lang/ClassNotFoundException.java b/classpath/java/lang/ClassNotFoundException.java index 86e6b82c8c..361525b917 100644 --- a/classpath/java/lang/ClassNotFoundException.java +++ b/classpath/java/lang/ClassNotFoundException.java @@ -25,4 +25,9 @@ public class ClassNotFoundException extends Exception { public ClassNotFoundException() { this(null, null); } + + public Throwable getException() { + return cause2; + } + } diff --git a/classpath/java/util/Arrays.java b/classpath/java/util/Arrays.java index 2357103eca..b60ef7d0f9 100644 --- a/classpath/java/util/Arrays.java +++ b/classpath/java/util/Arrays.java @@ -485,29 +485,69 @@ public class Arrays { }; } + private static void checkRange(int len, int start, int stop) { + if (start < 0) { + throw new ArrayIndexOutOfBoundsException(start); + } + if (stop > len) { + throw new ArrayIndexOutOfBoundsException(stop); + } + if (start > stop) { + throw new IllegalArgumentException("start(" + start + ") > stop(" + stop + ")"); + } + } + public static void fill(int[] array, int value) { for (int i=0;i void fill(T[] array, T value) { for (int i=0;i void fill(T[] array, int start, int stop, T value) { + checkRange(array.length, start, stop); + for (int i=start;i newLength ? newLength : array.length;