Possible bug with Intention: Add override annotation [RESOLVED]

Hi folks,

I've been working with Idea for 6 months and one thing that's more annoying than a bug itself, is the feature to override and implement methods. Nowadays it does not cause any compilation problem (with Maven I got, in some version, a compilation problem, I don't remember exaclty which version it was), but is very boring remove the @Override on methods that aren't, actually, not overriden.

Look at the description message for this intention, that IDEA gives itself:

"This intention adds standard Java 5.0 annotation @Override to the method which has been found to override non-abstract method in the base class."

But, if we implement any method from an interface (like pratically always in EJBs), it comes with @Override by default and it's in my opinion wrong, isn't it? Every method declared in interfaces are implicity public and abstract, the same occurs with abstract methods declared in abstract classes, why does this happen?

This will be perfect if it put, by default, @Override on methods that really override something. Thus, our code will be clean and we'll be sure when we're overriding or implementing.

It's just a suggestion, what do you guys think about it?

=]

2 comments
Comment actions Permalink

This behavior is not a bug. The @Override annotation on implementations of interface methods is allowed since Java 6, and serves exactly the same purpose as @Override on implementations of abstract methods: it lets you detect cases when your code no longer does what you expect because of a change in the signature of the base class method which wasn't propagated to the implementing class.

0
Comment actions Permalink

Good to know that! Thanks for your reply, I didn't know but it makes sense for me now.

0

Please sign in to leave a comment.