From 6462c159aa36d30123fb30cdaf5d1f4c9eb5acb2 Mon Sep 17 00:00:00 2001 From: Marcin Olawski Date: Sat, 7 Feb 2015 21:12:04 +0100 Subject: [PATCH 1/2] Add ArrayIndexOutOfBoundsException(int) and ClassNotFoundException.getException(). --- classpath/java/lang/ArrayIndexOutOfBoundsException.java | 4 ++++ classpath/java/lang/ClassNotFoundException.java | 5 +++++ 2 files changed, 9 insertions(+) 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; + } + } From ff17455baa7ab8ea713412e6ee5e777ad524f498 Mon Sep 17 00:00:00 2001 From: Marcin Olawski Date: Sat, 7 Feb 2015 21:12:48 +0100 Subject: [PATCH 2/2] Add Arrays.fill(* a,int start,int stop,* value). --- classpath/java/util/Arrays.java | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) 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;