Sunday, November 12, 2006

javac should warn about missing @Override annotation

Java5 includes a great metadata system called Annotations. One of them is really good for catching a common bug--a method that should override a base class method, but is misnamed or has the wrong argument types. It's called @Override.

But what would make this annotation really useful is an optional compiler warning that would inform you of all the overridden methods that do not have the @Override annotation, so that you can cover all your methods to make sure that things that should override something really do and things that should not really do not.

There's an outstanding filed bug for this feature, but it doesn't look like it's going to get implemented...