Community
Participate
Working Groups
Build ID: M20080221-1800 Steps To Reproduce: Please see the code snippet below that exhibits this problem. No combination of compiler settings available on the Eclipse compiler dialogue bring Eclipse's behaviour in line with Sun's. 1. Declare a method that defines a parameterised type as extending some type, and uses this parameterised type more than once in its arguments. 2. Call that method specifying one parameter correctly and one raw. 3. Compile with both Eclipse and Sun Java 5 SDK. More information: public class Test { public static void main(String[] args) { Test test = new Test(); /* OK: Bob.class is correct. No idea about the Thingy */ test.doStuff(Bob.class, new Thingy()); /* * This line will fail when compiled with the Java 5 SDK: * * Test.java:25: <T>doStuff(java.lang.Class<T>,Thingy<T>) in Test cannot be applied to (java.lang.Class<Bill>,Thingy) * test.doStuff(Bill.class, new Thingy()); * ^ * Note: Test.java uses unchecked or unsafe operations. * Note: Recompile with -Xlint:unchecked for details. * 1 error */ test.doStuff(Jim.class, new Thingy()); } <T extends Bob> void doStuff(Class<T> klass, Thingy<T> thingy) { } } class Jim { } class Bob { } class Bob2 extends Bob { } class Thingy<T extends Bob> { }
I believe the inference is detecting presence of raw type Thingy, and thus elects a raw form of the method to be invoked. Hence a warning, and no error.
Added GenericTypeTest#test1322-1328 (some disabled until resolution)
ECJ shouldn't be erasing entire method signature in presence of unchecked conversion during type inference. It should strictly apply JLS15.12.2.6 instead (erase return type & thrown exceptions).
also see bug 258798
Closing as dup of 258798. Strict application of 15.12.2.6 is addressing the problem. *** This bug has been marked as a duplicate of bug 258798 ***
Verified for 3.5M5 using build I20090127-0100.