Files
openide/java/java-impl/resources/inspectionDescriptions/OverridableMethodCallDuringObjectConstruction.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

35 lines
1.2 KiB
HTML

<html>
<body>
Reports calls to overridable methods of the current class during object construction.
<p>A method is called during object construction if it is inside a:
<ul>
<li>Constructor</li>
<li>Non-static instance initializer</li>
<li>Non-static field initializer</li>
<li><code>clone()</code> method</li>
<li><code>readObject()</code> method</li>
<li><code>readObjectNoData()</code> method</li>
<p>Methods are overridable if they are not declared as <code>final</code>, <code>static</code>, or <code>private</code>.
Package-local methods are considered safe, even though they are overridable. Such calls may result in subtle bugs,
as object initialization may happen before the method call.</p>
<p><b>Example:</b></p>
<pre><code>
class Parent {
void someMethod() { }
}
class Child extends Parent {
Child() {
someMethod();
}
}
</code></pre>
<!-- tooltip end -->
<p>This inspection shares the functionality with the following inspections:</p>
<ul>
<li>Abstract method called during object construction</li>
<li>Overridden method called during object construction</li>
</ul>
<p>Only one inspection should be enabled at once to prevent warning duplication.</p>
</body>
</html>