public class FinalizeImplementationCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
This Check detects 3 most common cases of incorrect finalize() method implementation:
1. Negates effect of superclass finalize:
protected void finalize() { }
protected void finalize() { doSomething(); }
2. Useless (or worse) finalize:
protected void finalize() { super.finalize(); }
3. Public finalize:
public void finalize(){
try {doSomething();}
finally {super.finalize()}
}| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY_MISSED_SUPER_FINALIZE_CALL
The key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_KEY_MISSED_TRY_FINALLY
The key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_KEY_PUBLIC_FINALIZE
The key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_KEY_USELESS_FINALIZE
The key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
FinalizeImplementationCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST methodDefToken) |
beginTree, clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeveritypublic static final String MSG_KEY_MISSED_TRY_FINALLY
public static final String MSG_KEY_PUBLIC_FINALIZE
public static final String MSG_KEY_USELESS_FINALIZE
public static final String MSG_KEY_MISSED_SUPER_FINALIZE_CALL
public int[] getDefaultTokens()
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getAcceptableTokens()
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getRequiredTokens()
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST methodDefToken)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2021. All rights reserved.