0

I've removed an unused method from an interface, and expected javac and Eclipse to complain about the fact that my implementing class still claims to override it:

@Override    
public void thisMethodNoLongerOverridesAnything() {}

However, I don't get an error or even a warning.

Is there a way to configure javac or Eclipse to complain in this case?

GripnRip
  • 47
  • 3

4 Answers4

5

According to the API doc of @Override

If a method is annotated with this annotation type compilers are required to generate an error message unless at least one of the following conditions hold:

  • The method does override or implement a method declared in a supertype.
  • The method has a signature that is override-equivalent to that of any public method declared in Object.

So either your mothod still overrides something, or you've found a bug in both javac and eclipse, which I doubt.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
  • I thinks its more likely just a bug in eclipse, there is nothing that suggests is has to be a bug in both. If I manually compile it then it reports the error correctly. – GripnRip Apr 05 '12 at 16:07
0

Errors will come definitely.

interface A{ void funA(); }

class Test implements A{
@Override
public void funA(){

}
@Override
public void B(){

}
}

Errors: The method B() of type Test must override or implement a supertype method

Sugessions: create B() in supertype A 
            remove Override annotation
Chandra Sekhar
  • 18,914
  • 16
  • 84
  • 125
0

In Eclipse:

Properties > Java Compiler > Errors/Warnings

The @Override annotation is under Annotations and ignored by default.

EDIT: Just re-read the question. You want to be warned if you have an unnecessary @Override and not when you are missing it.

radimpe
  • 3,197
  • 2
  • 27
  • 46
0

If you're using JDK 1.5 the @Override annotation is ignored.

Take a look at this (-> it can be also that the JDK Compliance in the eclipse preferences is set to 1.5) .

Community
  • 1
  • 1
Noam
  • 1,018
  • 7
  • 18