-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.5.1
Name: laC46010 Date: 03/24/98
JDK1.2beta3N fails to pass the JCK-114a test case: lang/CONV/conv083/conv08303/conv08303.html
Particularly, legal attempt to cast an array of a class type to an interface array type
throws java.lang.ClassCastException exception even if the class implements that interface.
See an reduced example below.
Note that when x[0] is initialized (uncomment "//x[0] = new C3();")
test works fine and ClassCastException is not thrown.
------------------------- run --------------------------
> java -fullversion
java full version "JDK-1.2beta3-N"
> javac -d /tmp conv08303.java
> java -verify conv08303
x:[LC2;@c084138e
x[0]:null
java.lang.ClassCastException: java.lang.Object
at conv08303.main(conv08303.java:16)
------------------------- run with init-ed x[0] -------
> javac -d /tmp conv08303.java
> java -verify conv08303
x:[LC2;@c0842f9c
x[0]:C3@c08c2f9c
v:[LC2;@c0842f9c
------------------------- conv08303.java --------------------------
interface I1 { int a = 777; }
interface I2 extends I1 { int b = 33; }
class C1 implements I2 { int i; }
class C2 extends C1 implements I1 { float f; }
class C3 extends C2 { double d; }
public class conv08303 {
public static void main(String args[]) {
I2 v[];
I1 x[];
x = new C2 [5];
//x[0] = new C3();
System.out.println("x:"+x);
System.out.println("x[0]:"+x[0]);
v = (I2 []) x;
System.out.println("v:"+v);
}
}
-----------------------------------------------------------------------------
======================================================================