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

22 lines
769 B
HTML

<html>
<body>
Reports implementations of, and calls to, the <code>clone()</code> method and uses of the <code>java.lang.Cloneable</code> interface.
<p>Some coding standards prohibit the use of <code>clone()</code>, and recommend using a copy constructor or
a <code>static</code> factory method instead.</p>
<p>The inspection ignores calls to <code>clone()</code> on arrays because it's a correct and compact way to copy an array.</p>
<p><b>Example:</b></p>
<pre><code>
class Copy implements Cloneable /*warning*/ {
public Copy clone() /*warning*/ {
try {
return (Copy) super.clone(); // warning
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
}
}
</code></pre>
<!-- tooltip end -->
</body>
</html>