Community
Participate
Working Groups
package noel.bugs; import java.util.HashMap; import java.util.Map; /** * Without the cast on the relevant line, the SUN compiler (JDK1.5.0_06) will flag an error. * * With the cast, Eclipse issues a warning that the cast is unnecessary. But as far as I can * tell, the cast really is necessary. */ public class EclipseGenericsBug { public static class DatabaseObject { } public static class ObjectFormUI<T extends DatabaseObject> { } private static final Map<Class<? extends DatabaseObject>, Class<? extends ObjectFormUI>> uiMap = new HashMap<Class<? extends DatabaseObject>, Class<? extends ObjectFormUI>>(); private EclipseGenericsBug() { } public static <T extends DatabaseObject> Class<? extends ObjectFormUI<T>> getUI(Class<T> persistentClass) { // >>>>>> THIS LINE IS THE CRITICAL ONE <<<<<<< return (Class<? extends ObjectFormUI<T>>) uiMap.get(persistentClass); // >>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<< } }
Works fine now. We resolved some extraneous unnecessary cast diagnostics in presence of unchecked conversions. Added GenericTypeTest#test875
Also added GenericTypeTest#test876