-
Bug
-
Resolution: Fixed
-
P4
-
6u10, 7
-
b44
-
generic, x86
-
generic, linux
-
Verified
Description:
Compiler throws error for what seems to be a valid cast to a type in which both the qualifying type and inner class are parameterized.
<code>
bash-3.00$
<code>
bash-3.00$ cat GenericOuter.java
public class GenericOuter<S> {
class GenericInner<T> extends LinkedList<T>{
}
public static void main(String...args){
GenericOuter.GenericInner g1 = ( GenericOuter.GenericInner)new LinkedList<String>();
GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
}
}
</code>
Compilation result is :
<output>
GenericOuter.java:8: ')' expected
GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
^
GenericOuter.java:8: ';' expected
GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
^
GenericOuter.java:8: illegal start of expression
GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
</output>
<version>
/net/sqindia/export/disk09/jdk/7/latest/binaries/solsparc/bin/java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b24)
Java HotSpot(TM) Client VM (build 12.0-b01, mixed mode)
bash-3.00$ uname -a
SunOS hrajan 5.10 Generic sun4u sparc SUNW,Sun-Blade-100
Compiler throws error for what seems to be a valid cast to a type in which both the qualifying type and inner class are parameterized.
<code>
bash-3.00$
<code>
bash-3.00$ cat GenericOuter.java
public class GenericOuter<S> {
class GenericInner<T> extends LinkedList<T>{
}
public static void main(String...args){
GenericOuter.GenericInner g1 = ( GenericOuter.GenericInner)new LinkedList<String>();
GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
}
}
</code>
Compilation result is :
<output>
GenericOuter.java:8: ')' expected
GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
^
GenericOuter.java:8: ';' expected
GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
^
GenericOuter.java:8: illegal start of expression
GenericOuter<String>.GenericInner<String> g2 = ( GenericOuter<String>.GenericInner<String>)new LinkedList<String>(); //Compilation Error
</output>
<version>
/net/sqindia/export/disk09/jdk/7/latest/binaries/solsparc/bin/java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b24)
Java HotSpot(TM) Client VM (build 12.0-b01, mixed mode)
bash-3.00$ uname -a
SunOS hrajan 5.10 Generic sun4u sparc SUNW,Sun-Blade-100
- duplicates
-
JDK-6964597 Cannot cast to non-static inner class of generic outer class
- Closed
-
JDK-6971958 Missing unchecked warning on cast to inner class of generic class
- Closed
- relates to
-
JDK-6667132 Cast to partially raw type(rare type) should not be allowed
- Closed
-
JDK-6790039 overhaul cast-conversion (umbrella)
- Closed
-
JDK-6795580 parser confused by square brackets in qualified generic cast
- Closed
-
JDK-6481655 Parser confused by combination of parens and explicit type args
- Closed
(1 relates to)