summaryrefslogtreecommitdiff
path: root/java/lang/reflect/Array.java
diff options
context:
space:
mode:
authorJohn Keiser <shalom@gnu.org>1998-07-15 19:51:15 +0000
committerJohn Keiser <shalom@gnu.org>1998-07-15 19:51:15 +0000
commitffe2e45d8bc80c0bfcf906cbfc69604e4b8f2a99 (patch)
tree29ddbd1430ef8d51469396df69026222c6f3267e /java/lang/reflect/Array.java
parentadc56f7e96fdff78ae74c965ac407ba3859c34e2 (diff)
downloadclasspath-ffe2e45d8bc80c0bfcf906cbfc69604e4b8f2a99.tar.gz
Fixed it so it runs under all tests. Have one more test to do later.
Diffstat (limited to 'java/lang/reflect/Array.java')
-rw-r--r--java/lang/reflect/Array.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/java/lang/reflect/Array.java b/java/lang/reflect/Array.java
index 6f443ffba..c9fc7ba13 100644
--- a/java/lang/reflect/Array.java
+++ b/java/lang/reflect/Array.java
@@ -61,8 +61,8 @@ public final class Array {
**/
public static Object newInstance(Class componentType, int length)
throws NegativeArraySizeException {
- if(componentType.isAssignableFrom(objectClass)) {
- return createObjectArray(componentType, length);
+ if(componentType == Boolean.TYPE) {
+ return new boolean[length];
} else if(componentType==Byte.TYPE) {
return new byte[length];
} else if(componentType==Character.TYPE) {
@@ -80,7 +80,7 @@ public final class Array {
} else if(componentType==Void.TYPE) {
return null;
} else {
- return null;
+ return createObjectArray(componentType, length);
}
}
@@ -148,7 +148,7 @@ public final class Array {
} else if(array instanceof double[]) {
return new Double(((double[])array)[index]);
} else {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Parameter not an array.");
}
}
@@ -165,7 +165,7 @@ public final class Array {
if(array instanceof boolean[]) {
return ((boolean[])array)[index];
} else {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Not a boolean array.");
}
}
@@ -182,7 +182,7 @@ public final class Array {
if(array instanceof byte[]) {
return ((byte[])array)[index];
} else {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Array is not of appropriate type.");
}
}
@@ -217,7 +217,7 @@ public final class Array {
if(array instanceof char[]) {
return ((char[])array)[index];
} else {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Not a char array.");
}
}
@@ -303,7 +303,8 @@ public final class Array {
** @param array the array to set a value of.
** @param index the array index to set the value to.
** @param value the value to set.
- ** @exception IllegalArgumentException if <code>array</code> is not an array.
+ ** @exception IllegalArgumentException if <code>array</code> is not an array or the value
+ ** is of the wrong type for the array.
** @exception ArrayIndexOutOfBoundsException if <code>index</code> is out of bounds.
**/
public static void set(Object array, int index, Object value)
@@ -328,7 +329,7 @@ public final class Array {
} else if(value instanceof Double) {
setDouble(array,index,((Double)value).doubleValue());
} else {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Tried to set a value on a non-array.");
}
}
@@ -346,7 +347,7 @@ public final class Array {
if(array instanceof boolean[]) {
((boolean[])array)[index] = value;
} else {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Not a boolean array.");
}
}
@@ -478,7 +479,7 @@ public final class Array {
if(array instanceof double[]) {
((double[])array)[index] = value;
} else {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Array is not of appropriate primitive type");
}
}
@@ -510,7 +511,8 @@ public final class Array {
}
return retval;
} else {
- return newInstance(type,dimensions[0]);
+ Object toAdd = newInstance(type,dimensions[0]);
+ return toAdd;
}
}