Community
Participate
Working Groups
System: ======= Win2000, Eclipse 3.1M6 Test code: ========== import java.util.Collections; import java.util.Set; import java.util.TreeSet; public class Test { public interface Base { } abstract class Action<T extends Base> { } public class ActionImpl<T extends Base> extends Action<T> implements Comparable<ActionImpl> { public int compareTo(ActionImpl o) { return 0; } } public void test() { Set<ActionImpl> set = new TreeSet<ActionImpl>(); Collections.max(set); } } Javac compiles this code without warning but the Eclipse compiler produces the following error: "Bound mismatch: The generic method max(Collection<? extends T>) of type Collections is not applicable for the arguments (Collection<? extends Test.ActionImpl>) since the type Test.ActionImpl is not a valid substitute for the bounded parameter <T extends Object & Comparable<? super T>>" A workaround for the problem is to declare the variable as: Set<ActionImpl<Base>> set = new TreeSet<ActionImpl<Base>>(); However given that it compiles with javac I have submitted this as a bug.
Added GenericTypeTest#test718. Works fine in latest. M6 is old, since then M7 and RC1 got issued.
Also note that both compilers are warning about: 1. WARNING in Test.java (at line 21) Collections.max(set); ^^^^^^^^^^^^^^^^^^^^ Type safety: Unchecked invocation max(Collection<? extends X.ActionImpl>) of the generic method max(Collection<? extends T>) of type Collections