-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 6
-
b63
-
generic
-
generic, solaris_8
-
Verified
The following method can usefully be retrofitted with varargs:
public static
Object java.lang.reflect.Array.newInstance(
Class<?> componentType,
int... dimensions);
See below for the suggested fix and JUnit testcase:
A DESCRIPTION OF THE FIX :
version :
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b54)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b54, mixed mode, sharing)
diff -u :
--- Array.java.old Wed Oct 12 14:58:53 2005
+++ Array.java.new Wed Oct 12 15:01:40 2005
@@ -85,7 +85,7 @@
* @exception NegativeArraySizeException if any of the components in
* the specified <code>dimensions</code> argument is negative.
*/
- public static Object newInstance(Class<?> componentType, int[] dimensions)
+ public static Object newInstance(Class<?> componentType, int... dimensions)
throws IllegalArgumentException, NegativeArraySizeException {
return multiNewArray(componentType, dimensions);
}
JUnit TESTCASE :
/** javac -Xbootclasspath/p:. Path5041975Test.java
* java -Xbootclasspath/p:. Path5041975Test
* @author remi
*/
public class Path5041975Test {
public static void main(String[] args) {
Object array=Array.newInstance(String.class, 2,3);
if (!(array instanceof String[][]))
throw new AssertionError("erreor in newInstance");
}
}
FIX FOR BUG NUMBER:
5041975
public static
Object java.lang.reflect.Array.newInstance(
Class<?> componentType,
int... dimensions);
See below for the suggested fix and JUnit testcase:
A DESCRIPTION OF THE FIX :
version :
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b54)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b54, mixed mode, sharing)
diff -u :
--- Array.java.old Wed Oct 12 14:58:53 2005
+++ Array.java.new Wed Oct 12 15:01:40 2005
@@ -85,7 +85,7 @@
* @exception NegativeArraySizeException if any of the components in
* the specified <code>dimensions</code> argument is negative.
*/
- public static Object newInstance(Class<?> componentType, int[] dimensions)
+ public static Object newInstance(Class<?> componentType, int... dimensions)
throws IllegalArgumentException, NegativeArraySizeException {
return multiNewArray(componentType, dimensions);
}
JUnit TESTCASE :
/** javac -Xbootclasspath/p:. Path5041975Test.java
* java -Xbootclasspath/p:. Path5041975Test
* @author remi
*/
public class Path5041975Test {
public static void main(String[] args) {
Object array=Array.newInstance(String.class, 2,3);
if (!(array instanceof String[][]))
throw new AssertionError("erreor in newInstance");
}
}
FIX FOR BUG NUMBER:
5041975