Inspectopedia
 
2024.3

'clone()' method in non-Cloneable class

Warning
New
Last modified: 03 December 2024

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.