@OverridingMethodsMustInvokeSuper
annotation in super method is ignored by overriding method JAVA-S0001The super method is annotated with @OverridingMethodsMustInvokeSuper
, but the overriding method isn't calling the super method.
This can cause bugs since there may be logic that depends on the super method being called, hence the super method being marked with the @OverridingMethodsMustInvokeSuper
annotation.
class Super {
@OverridingMethodsMustInvokeSuper
void method() {
// ...
}
}
class Bad extends Super {
@Override
void method() {
// ...
}
}
class Good extends Super {
@Override
void method() {
// This could be anywhere in the method as required, but it should exist.
super.method();
// ...
}
}
Make sure to call the super method at some point in the overriding method.