1
Class A extends B{    
    protected void executeImpl(){
        super.executeImpl();
    }
}

Above class in being Injected in third class

Class C{

    A a;

    public void execute(){
    a.executeImpl()

    }

    }

ERROR: Description Assignee Resource New issue Useless Overriding Method : Overriding method merely calls super

Deepak Negi
  • 119
  • 3
  • 13
  • http://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why – seenukarthi Aug 17 '15 at 05:21
  • 4
    The error says why pretty clearly: "Overriding method merely calls super " You don't add any new logic in the overriden method so there is no need to have it there. – trappski Aug 17 '15 at 06:00
  • Hi Karthik, As mentioned it is something which SONARQube is showing... if i put or don't put error remains same. – Deepak Negi Aug 17 '15 at 06:02

1 Answers1

1

The @Override annotation can only be added on inherited method. This does not mean that if you remove the annotation the method is not inherited anymore. It is still inherited ! And therefore the rule is still valid as it did not change the semantic of your program to remove the annoation.

benzonico
  • 10,635
  • 5
  • 42
  • 50
  • Shall i remove super.executeImpl(); – Deepak Negi Aug 17 '15 at 12:51
  • What the rule is suggesting to you is that having this method is probably useless as having no code at all would have the same behaviour. – benzonico Aug 17 '15 at 14:00
  • No, you shall remove the whole method, since it doesn't do anything that wouldn't happen anyway even without explicitly having this overriding method. – Florian Schaetz Aug 18 '15 at 07:49
  • of course not, you should remove the whole method as this implementation with the call to super.executeImpl() (which I encourage you to have a closer look at what this exactly means) is exactly the same as if you have no method in this case. – benzonico Aug 18 '15 at 09:44