Community
Participate
Working Groups
The following source was tested with: Eclipse 3.1 200410260800 Integration Build, Sun JDK 5.0 with source level 1.5 turned on for Eclipse project. JDK 5 was extended to include return types into full method signature check when overloading Generics methods inside a class. Therefore the following code snippet gets a clear compile in Sun JDK 5 whereas Eclipse does not compile the source with the following two errors: 1.) The return type is incompatible with InterfaceB.getValue(String), InterfaceA.getValue(String) 2.) Duplicate method getValue(String) in type ImplementationClass InterfaceA.java file: public interface InterfaceA { <T extends Integer> T getValue(String value); } InterfaceB.java file: public interface InterfaceB { <T extends Double> T getValue(String value); } ImplementationClass.java file: public class ImplementationClass implements InterfaceA, InterfaceB { public <T extends Integer> T getValue(String value) { return null; } public <T extends Double> T getValue(String value) { return null; } } And there is also another problem. The IDE does not support quick fixes when implementing these two interface types in empty implementation class. There is a quick fix offered for adding unimplemented methods but nothing happens when selecting the quick fix.
*** Bug 77562 has been marked as a duplicate of this bug. ***
But you cannot send either method. javac reports that the methods are ambiguous. X.java:6: reference to getValue is ambiguous, both method <T>getValue(int) in X and method <T>getValue(int) in X match I think we are better off reporting these methods as duplicates. Now if the type variable is also a parameter type then we have a bug, which will be fixed soon. See bug 73971 .