Community
Participate
Working Groups
Hello, I'm currently using 3.1m3 and am curious on why the following code builds fine within the IDE ( making sure the project is using the 1.5 ( 5 ) compiler ), but does NOT build fine when using the 1.5 javac.exe. Here's the code: A.java ===== public class A { } B.java ===== public class B extends A { } C.java ====== import java.util.List; public interface C { List< A > getIt(); } D.java ====== import java.util.List; public interface D extends C { List< B > getIt(); } When building these files from the command line, I get the following error: ****************************************************************** F:\temp>javac *.java D.java:4: getIt() in D clashes with getIt() in C; attempting to use incompatible return type found : java.util.List<B> required: java.util.List<A> List< B > getIt(); ^ 1 error ******************************************************************* But when I build those same files in the Eclipse 3.1m3 IDE, builds fine. I believe this code should NOT build. In order to make it build from the command line, I have to change C.java so that the getIt() method's return type looks like this: List< ? extends A > Regards, Cameron
The "why" is simple: Eclipse defines its own Java compiler. Now you may have found a bug...
This was fixed last week.
Verified in 200412140800