Files
openide/java/java-impl/resources/inspectionDescriptions/RefusedBequest.html
2025-02-05 04:43:28 +00:00

48 lines
1.4 KiB
HTML

<html>
<body>
Reports methods that override a super method without calling it.
This is also known as a <i>refused bequest</i>.
Such methods may represent a failure of abstraction and cause hard-to-trace bugs.
<p>
The inspection doesn't report methods overridden from <code>java.lang.Object</code>, except for <code>clone()</code>.
The <code>clone()</code> method should by convention call its super method,
which will return an object of the correct type.</p>
<p><b>Example 1:</b></p>
<pre><code>
class A {
@Override
public Object clone() {
// does not call 'super.clone()'
return new A();
}
}
</code></pre>
<p><b>Example 2:</b></p>
<pre><code>
interface I {
default void foo() {}
}
class A implements I {
// warning on method when
// 'Ignore 'default' super methods' is disabled
@Override
public void foo(){}
}
</code></pre>
<!-- tooltip end -->
<p>Configure the inspection:</p>
<ul>
<li>
Use the <b>Only report when super method is annotated by</b> option to ignore super methods marked with the annotations
from the provided list. You can manually add annotations to the list.
</li>
<li>
Use the <b>Ignore empty super methods</b> option to ignore super methods that are either empty or only throw an exception.
</li>
<li>
Use the <b>Ignore 'default' super methods</b> option to ignore <code>default</code> super methods from interfaces.
</li>
</ul>
</body>
</html>