Inspectopedia Help

Method does not call super method

Reports methods that override a super method without calling it. This is also known as a refused bequest. Such methods may represent a failure of abstraction and cause hard-to-trace bugs.

The inspection doesn't report methods overridden from java.lang.Object, except for clone(). The clone() method should by convention call its super method, which will return an object of the correct type.

Example 1:

class A { @Override public Object clone() { // does not call 'super.clone()' return new A(); } }

Example 2:

interface I { default void foo() {} } class A implements I { // warning on method when // 'Ignore 'default' super methods' is disabled @Override public void foo(){} }

Configure the inspection:

  • Use the Only report when super method is annotated by option to ignore super methods marked with the annotations from the provided list. You can manually add annotations to the list.

  • Use the Ignore empty super methods option to ignore super methods that are either empty or only throw an exception.

  • Use the Ignore 'default' super methods option to ignore default super methods from interfaces.

Inspection options

Here you can find the description of settings available for the Method does not call super method inspection, and the reference of their default values.

Only report when super method is annotated by

Default: Selected

Ignore empty super methods

Not selected

Ignore 'default' super methods

Not selected

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024