Files
openide/java/java-impl/resources/inspectionDescriptions/OverridableMethodCallDuringObjectConstruction.html
Egor Malyshevandintellij-monorepo-bot d7ca05c10e Correcting syntax: missing UL and text inside a UL that doesn't belong there
(cherry picked from commit e6d6273cd132385468377c8b9ad92c23f40d3209)

IJ-MR-175854

GitOrigin-RevId: e8cd63225f9067b1af0b02875d1ea24b300c5825
2025-09-17 14:54:14 +00:00

37 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>
</ul>
<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>