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:
Example 2:
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
MethodDoesntCallSuperMethod- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
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
defaultsuper 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 value:
Selected- Ignore empty super methods
Default value:
Not selected- Ignore 'default' super methods
Default value:
Not selected
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |