'clone()' method in non-Cloneable class
Reports classes that override the clone()
method but don't implement the Cloneable
interface. This usually represents a programming error.
Use the Only warn on 'public' clone methods option to ignore methods that aren't public
.
For classes designed to be inherited, you may choose to override clone()
and declare it as protected
without implementing the Cloneable
interface and decide whether to implement the Cloneable
interface in subclasses.
Inspection options
Option | Type | Default |
---|---|---|
Only warn on 'public' clone methods | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023