Inspectopedia 2025.2 Help

'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.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

CloneInNonCloneableClass
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Cloning issues

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

Here you can find the description of settings available for the 'clone()' method in non-Cloneable class inspection, and the reference of their default values.

Only warn on 'public' clone methods

Default value:

Selected

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection CloneInNonCloneableClass

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025