Community
Participate
Working Groups
Forked from https://bugs.eclipse.org/bugs/show_bug.cgi?id=93377 (bug 5 there). Reproduced with 3.1 RC1 (aka build I20050527-1300). On the following code: public class X<T> { protected static final Class<X<?>> theClass = (Class<X<?>>) X.class; } Eclipse reports a warning: Severity Description Resource In Folder Location Creation Time Type safety: The cast from Class<X> to Class<X<?>> is actually checking against the erased type Class whereas javac reports an error: X.java:2: inconvertible types found : java.lang.Class<X> required: java.lang.Class<X<?>> protected static final Class<X<?>> theClass = (Class<X<?>>) X.class; ^ 1 error
Created attachment 22045 [details] Batch compiler test case that shows the problem Note that _test29 needs to be renamed as test29 to get activated.
I believe this is a bug in javac.
Actually, I take previous comment back. The types involved are provably distinct, and thus cast should be rejected. Added GenericTypeTest#test0965. Fixed
Verified for 3.2 RC1 using build I20060413-0010.