Why is javac failing on @Override annotation
The @Override
annotation spec changed in Java 1.6. In Java 1.5, the compiler did not allow the @Override
annotation on implemented interface methods, but in 1.6 it does. First search result I found is a blog post here.. It was not well documented, but it did change.
Eclipse is adding it because your Eclipse is set for 1.6 compliance. You should try to keep your build and eclipse environments on the same version of Java. It's unclear to me by your specifying Cruise Control is running Java 5 on whether or not it is compiling using a separate JDK6 or not.
Separate from the above 1.5 vs 1.6 @Override
annotation rules, remember that Eclipse has its own compiler implementation (not javac
) and will occasionally have different behavior. Whenever something compiles in Eclipse, but not Ant or Maven, you will need to find a way to make both compilers happy.
I can't really explain the problem you're seeing but it seems to be related to the fact that JDK 5 will not allow @Override
on implemented methods of an interface, only on overridden methods present in a super class.
JDK 6 will allow @Override
on any of them.
If your ant build fails it may be passing a source
parameter to javac, asking for JDK 5 compliance.
@Override
tags for implemented methods are new to Java 1.6. In Java 1.5 @Override
is only correct when overriding a method in a base class. Read more here and here.