Bug 97494

Summary: [1.5][compiler] Inappropriate error level and message for generic type mismatch
Product: [Eclipse Project] JDT Reporter: Maxime Daniel <maxime_daniel>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: vulcannis
Version: 3.1   
Target Milestone: 3.2 RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Batch compiler test case that shows the problem none

Description Maxime Daniel CLA 2005-05-31 10:39:57 EDT
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
Comment 1 Maxime Daniel CLA 2005-05-31 10:44:48 EDT
Created attachment 22045 [details]
Batch compiler test case that shows the problem

Note that _test29 needs to be renamed as test29 to get activated.
Comment 2 Philipe Mulet CLA 2005-05-31 12:59:43 EDT
I believe this is a bug in javac.
Comment 3 Philipe Mulet CLA 2006-04-04 07:40:00 EDT
Actually, I take previous comment back. The types involved are provably distinct, and thus cast should be rejected.

Added GenericTypeTest#test0965.
Fixed
Comment 4 Frederic Fusier CLA 2006-04-13 14:11:56 EDT
Verified for 3.2 RC1 using build I20060413-0010.