Class SuperCloneCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.puppycrawl.tools.checkstyle.checks.coding.AbstractSuperCheck
-
- com.puppycrawl.tools.checkstyle.checks.coding.SuperCloneCheck
-
- All Implemented Interfaces:
Configurable
,Contextualizable
public class SuperCloneCheck extends AbstractSuperCheck
Checks that an overriding
clone()
method invokessuper.clone()
. Does not check native methods, as they have no possible java defined implementation.Reference: Object.clone().
To configure the check:
<module name="SuperClone"/>
Example:
class A { public Object clone() { // OK return super.clone(); } } class B { private int b; public B clone() { // violation, does not call super.clone() B other = new B(); other.b = this.b; return other; } } class C { public C clone() { // OK return (C) super.clone(); } }
Parent is
com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
-
missing.super.call
- Since:
- 3.2
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Field Summary
-
Fields inherited from class com.puppycrawl.tools.checkstyle.checks.coding.AbstractSuperCheck
MSG_KEY
-
-
Constructor Summary
Constructors Constructor Description SuperCloneCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
getMethodName()
Returns the name of the overriding method.-
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.coding.AbstractSuperCheck
beginTree, getAcceptableTokens, getDefaultTokens, getRequiredTokens, leaveToken, visitToken
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, log, setFileContents, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Method Detail
-
getMethodName
protected java.lang.String getMethodName()
Description copied from class:AbstractSuperCheck
Returns the name of the overriding method.- Specified by:
getMethodName
in classAbstractSuperCheck
- Returns:
- the name of the overriding method.
-
-