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;