-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
5.0
-
sparc
-
solaris_8
-
Verified
Name: ngR10089 Date: 01/28/2004
The latest spec of "Adding Generics to the Java Programming Language: Public
Draft Specification, Version 2.0", 5.4 reads:
"A value of type S can be cast to a parameterized type T if one of the
following two conditions holds:
o T is a subtype of S, and there are no other subtypes of S with the
same erasure (see Section 6.1) as T.
o . . ."
However javac (jdk1.5.0-b35) successfully compiles test below.
> javac -d . -source 1.5 *.java
Note: test.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> java -Xfuture p.test
++ 1
Test
++ 2
Test
>
--------------- test.java-------------
package p;
import java.io.PrintStream;
class cl_b<A> {
A value;
}
class cl_a<A> extends cl_b<A> {
cl_a(A value) {
this.value = value;
}
}
public class test {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
boolean result = true;
cl_b y = new cl_a<String>("Test");
cl_a<Integer> z1;
cl_a<String> z;
try {
z = (cl_a<String>)y;
out.println("++ 1");
out.println(z.value);
} catch (Throwable e) {
out.println("==1 "+e);
}
try {
z1 = (cl_a<Integer>)y;
out.println("++ 2");
out.println(z1.value);
} catch (Throwable e) {
out.println("==2 "+e);
}
return 0/*STATUS_PASSED*/;
}
}
---------------------------------------
New JCK tests
lang/EXPR/expr674/expr67402/expr67402.html
fails due to this bug.
======================================================================
The latest spec of "Adding Generics to the Java Programming Language: Public
Draft Specification, Version 2.0", 5.4 reads:
"A value of type S can be cast to a parameterized type T if one of the
following two conditions holds:
o T is a subtype of S, and there are no other subtypes of S with the
same erasure (see Section 6.1) as T.
o . . ."
However javac (jdk1.5.0-b35) successfully compiles test below.
> javac -d . -source 1.5 *.java
Note: test.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> java -Xfuture p.test
++ 1
Test
++ 2
Test
>
--------------- test.java-------------
package p;
import java.io.PrintStream;
class cl_b<A> {
A value;
}
class cl_a<A> extends cl_b<A> {
cl_a(A value) {
this.value = value;
}
}
public class test {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
boolean result = true;
cl_b y = new cl_a<String>("Test");
cl_a<Integer> z1;
cl_a<String> z;
try {
z = (cl_a<String>)y;
out.println("++ 1");
out.println(z.value);
} catch (Throwable e) {
out.println("==1 "+e);
}
try {
z1 = (cl_a<Integer>)y;
out.println("++ 2");
out.println(z1.value);
} catch (Throwable e) {
out.println("==2 "+e);
}
return 0/*STATUS_PASSED*/;
}
}
---------------------------------------
New JCK tests
lang/EXPR/expr674/expr67402/expr67402.html
fails due to this bug.
======================================================================