- This topic has 3 replies, 2 voices, and was last updated 15 years, 8 months ago by Brian Fernandes.
-
AuthorPosts
-
Christophe TAVERNEMemberHi,
With 7.0 and 7.1 versions:
When I implement one interface into a class and when I use “Add unimplemented methods” option, I get “@override” annotations on methods added automatically.
I think it is a mistake.
regards,
Bal.
Brian FernandesModeratorBal,
This is not a bug, the @Override annotations let the compiler know that these methods must override methods in the interface / super class. This allows eclipse to flag this as a warning or error in case you make a change to the method signature such that it no longer overrides a method in the interface or super class. You can read more about this annotation here: http://java.sun.com/docs/books/tutorial/java/javaOO/annotations.html
If you don’t want these annotations generated, go to Window > Preferences > Java > Code Style and uncheck the “Add ‘@Override’ annotation for new overriding methods” checkbox.
Hope this helps.
Christophe TAVERNEMemberYou re perfectly right.
But I’m in a complex case. We have done several tests and I will explain…
My personal myeclipse come from one 6.6 update.
Co-workers have a fresh 7.1 install.When they use “Add unimplemented methods” option, the “@override” annotation is automatically added to the methods.
On my configuration when I do the same, I get any annotation “@override” added. ???
But all of them, we have the “Add ‘@Override’ annotation for new overriding methods” checkbox selected into the myeclipse configuration
So when they automatically add “@override” annotation on class implements interface and they commit, I always get a myeclipse error when I update SVN.
The error message I get is: “The method test() of type ManageBean must override a superclass method ManageBean .java projectEJB/src/com/test/ejb/ManageBean line 857 Java Problem”
I hope I’m clear. It’s a little hard to explain.
But I’m think it’s an upgrade bug because I’m alone to have this problem.
regards,
Brian FernandesModeratorBal,
On my configuration when I do the same, I get any annotation “@override” added. ???
Could you please clarify what you mean here? When you “add unimplemented methods” you do get the @Override annotation, correct?
The error message I get is: “The method test() of type ManageBean must override a superclass method ManageBean .java projectEJB/src/com/test/ejb/ManageBean line 857 Java Problem”
It is highly likely that this is reporting a real problem where your test() method does not override a method in the super class/interface when it should. If you feel that the test() method should not be overriding a super method, simply delete the @Override annotation.
As far as I know it is not possible to turn the error for @Override off, so if you and your colleagues have exactly the same code, I find it unlikely that you see the error but they don’t. Is this the case? Are they compiling their code with JDK 1.4?
-
AuthorPosts