public class SuperCloneCheck extends AbstractSuperCheck
Checks that an overriding clone() method invokes super.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
AutomaticBean.OutputStreamOptionsMSG_KEY| Constructor and Description |
|---|
SuperCloneCheck() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
getMethodName()
Returns the name of the overriding method.
|
beginTree, getAcceptableTokens, getDefaultTokens, getRequiredTokens, leaveToken, visitTokenclearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic SuperCloneCheck()
protected String getMethodName()
AbstractSuperCheckgetMethodName in class AbstractSuperCheckCopyright © 2001–2020. All rights reserved.