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

20 lines
672 B
HTML

<html>
<body>
Reports <code>clone()</code> methods without the <code>final</code> modifier.
<p>
Since <code>clone()</code> can be used to instantiate objects without using a constructor, allowing the <code>clone()</code>
method to be overridden may result in corrupted objects, and even in security exploits. This may be prevented by making the
<code>clone()</code> method or the enclosing class itself <code>final</code>.
</p>
<p><b>Example:</b></p>
<pre><code>
class Main implements Cloneable {
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
</code></pre>
<!-- tooltip end -->
</body>
</html>