Possible Duplicate:
Why does Eclipse complain about @Override on interface methods?
I have some Java code that was written using Eclipse and the Java 6 SDK, so methods that implement an interface are annotated with @Override
- an annotation that is legal in Java 6, but not in Java 5.
I'd like to compile the same code using the Java 5 SDK (javac
on Mac OS X 10.5). Everything compiles and runs fine except for the @Override
annotations. Is there any way I can get javac to ignore the @Override
annotations for this project, or is the only solution to remove them all?
It is not necessary, but it is highly recommended. It keeps you from shooting yourself in the foot. It helps prevent the case when you write a function that you think overrides another one but you misspelled something and you get completely unexpected behavior.
If you make any method static then it becomes a class method and not an object method and hence it is not allowed to be overridden as they are resolved at compilation time and overridden methods are resolved at runtime.
The @Override annotation allows other developers (and you, when you forget) to know that this method overrides something in a base class/interface, and it also allows the compiler to yell at you if you're not actually overriding anything in a base class.
Unfortunately, the only way is to actually remove the annotations.
If you do want to have your code compile and run with Java 5, you should develop targeting Java 5. Otherwise, you might accidentally rely on a Java 6 specific SDK methods and such.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With