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:
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
Option | Type | Default |
---|---|---|
Only report when super method is annotated by | Checkbox | true |
StringList | [javax.annotation.OverridingMethodsMustInvokeSuper, org.jetbrains.annotations.MustBeInvokedByOverriders] | |
Ignore empty super methods | Checkbox | false |
Ignore 'default' super methods | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |