Files
2025-02-05 04:43:28 +00:00

46 lines
1.6 KiB
HTML

<html>
<body>
Reports methods overriding superclass methods but are not annotated with <code>@java.lang.Override</code>.
<p>
Annotating methods with <code>@java.lang.Override</code> improves code readability since it shows the intent.
In addition, the compiler emits an error when a signature of the overridden method doesn't match the superclass method.
<p><b>Example:</b></p>
<pre><code>
class X {
public String toString() {
return "hello world";
}
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
class X {
@Override
public String toString() {
return "hello world";
}
}
</code></pre>
<!-- tooltip end -->
<p>Configure the inspection:</p>
<ul>
<li>
Use the <b>Ignore 'equals()', 'hashCode()' and 'toString()'</b> option to ignore these
<code>java.lang.Object</code> methods: <code>equals()</code>, <code>hashCode()</code>, and
<code>toString()</code>. The risk that these methods will disappear and
your code won't be compiling anymore due to the <code>@Override</code>
annotation is relatively small.
</li>
<li>
Use the <b>Ignore methods in anonymous classes</b> option to ignore methods
in anonymous classes.
</li>
<li>
Disable the <b>Highlight method when its overriding methods do not all have the '@Override' annotation</b> option to only
warn on the methods missing an <code>@Override</code> annotation, and not on overridden methods where one or more descendants are
missing an <code>@Override</code> annotation.
</li>
</ul>
</body>
</html>