FULL PRODUCT VERSION :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7600]
A DESCRIPTION OF THE PROBLEM :
The following code doesn't compile
package com.test;
public class TestCompile {
public static void main(String[] args) {
Class<?> clazz = (Class<? extends Generic<? super Object>>) Child.class;
}
}
interface Generic<T>{}
class Child implements Generic<Integer>{}
output from javac (1.6.0_20):
com\test\TestCompile.java:8: inconvertible types
found : java.lang.Class<com.test.Child>
required: java.lang.Class<? extends com.test.Generic<? super java.lang.Object>>
Class<?> clazz = (Class<? extends Generic<? super Object>>) Child.class;
^
1 error
when used jdk7 b107:
com\test\TestCompile.java:8: inconvertible types
Class<?> clazz = (Class<? extends Generic<? super Object>>) Child.class;
^
required: Class<? extends Generic<? super Object>>
found: Class<Child>
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.test;
public class TestCompile {
public static void main(String[] args) {
Class<?> clazz = (Class<? extends Generic<? super Object>>) Child.class;
}
}
interface Generic<T>{
}
class Child implements Generic<Integer>{
}
---------- END SOURCE ----------
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7600]
A DESCRIPTION OF THE PROBLEM :
The following code doesn't compile
package com.test;
public class TestCompile {
public static void main(String[] args) {
Class<?> clazz = (Class<? extends Generic<? super Object>>) Child.class;
}
}
interface Generic<T>{}
class Child implements Generic<Integer>{}
output from javac (1.6.0_20):
com\test\TestCompile.java:8: inconvertible types
found : java.lang.Class<com.test.Child>
required: java.lang.Class<? extends com.test.Generic<? super java.lang.Object>>
Class<?> clazz = (Class<? extends Generic<? super Object>>) Child.class;
^
1 error
when used jdk7 b107:
com\test\TestCompile.java:8: inconvertible types
Class<?> clazz = (Class<? extends Generic<? super Object>>) Child.class;
^
required: Class<? extends Generic<? super Object>>
found: Class<Child>
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.test;
public class TestCompile {
public static void main(String[] args) {
Class<?> clazz = (Class<? extends Generic<? super Object>>) Child.class;
}
}
interface Generic<T>{
}
class Child implements Generic<Integer>{
}
---------- END SOURCE ----------
- duplicates
-
JDK-6932571 Compiling Generics causing Inconvertible types
-
- Closed
-