Summary: | Compilation error with generic classes and subclasses | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Nicolas HERVE <n.herve> | ||||||
Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> | ||||||
Status: | VERIFIED INVALID | QA Contact: | |||||||
Severity: | normal | ||||||||
Priority: | P3 | CC: | amj87.iitr, daniel_megert, n.herve, pwebster, srikanth_sankaran | ||||||
Version: | 3.7 | ||||||||
Target Milestone: | 3.8 M4 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Nicolas HERVE
2011-07-13 06:09:45 EDT
Created attachment 199559 [details]
source code to reproduce the bug
(In reply to comment #0) > Build Identifier: 20100917-0705 This is a Helios build (probably (3.6.1). The example code compiles fine for me when using Indigo (3.7). It's my mistake, the build id is 20110615-0604. The previous one was the build id of the helios instance on which the code compiles well. Created attachment 199564 [details]
source code to reproduce the bug
The previsous attachement was also the bad version :-( This minimal test case fails to compile with javac5,6,7 and elicits nearly identical message: // --------------------------8<------------------------ interface AnInterface { } abstract class Task<Input> { } public class X<T extends AnInterface> { public class ExecutionContext { public class SubTask extends Task<String> { } public <Input> void doSomething( Class<? extends Task<Input>> method) { } public void start() { doSomething(SubTask.class); } } } // --------------------------8<------------------------ What do you think is the bug here ? I found the bug in my source code. In the minimal test case provided by Srikanth, the subclass SubTask is indirectly parameterized by T of class X. Thus the compiler is unable to know exactly what is SubTask.class. Having this subclass static or removing the generic parameterization on X will correct the bug. Now the main question is : why was this working fine in eclipse 3.6 ? The compilation, and more importantly, the execution were fine. (In reply to comment #7) > I found the bug in my source code. In the minimal test case provided by > Srikanth, the subclass SubTask is indirectly parameterized by T of class X. > Thus the compiler is unable to know exactly what is SubTask.class. Having this > subclass static or removing the generic parameterization on X will correct the > bug. Thanks for confirming this. > Now the main question is : why was this working fine in eclipse 3.6 ? It is called a bug ? :) >The > compilation, and more importantly, the execution were fine. Type unsafe code may not always produce visible problems. It is just that there is some set of constraints under which it could produce problems. Verified for 3.8M4 using build I20111202-0800. |