Class FinalizeImplementationCheck
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
-
- com.puppycrawl.tools.checkstyle.api.AbstractCheck
-
- com.github.sevntu.checkstyle.checks.coding.FinalizeImplementationCheck
-
- All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable,com.puppycrawl.tools.checkstyle.api.Contextualizable
public class FinalizeImplementationCheck extends com.puppycrawl.tools.checkstyle.api.AbstractCheckValidates finalize method implementation.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()} }- Since:
- 1.11.0
- Author:
- Max Vetrenko
-
-
Field Summary
Fields Modifier and Type Field Description static StringMSG_KEY_MISSED_SUPER_FINALIZE_CALLThe key is pointing to the warning message text in "messages.properties" file.static StringMSG_KEY_MISSED_TRY_FINALLYThe key is pointing to the warning message text in "messages.properties" file.static StringMSG_KEY_PUBLIC_FINALIZEThe key is pointing to the warning message text in "messages.properties" file.static StringMSG_KEY_USELESS_FINALIZEThe key is pointing to the warning message text in "messages.properties" file.
-
Constructor Summary
Constructors Constructor Description FinalizeImplementationCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]getAcceptableTokens()int[]getDefaultTokens()int[]getRequiredTokens()voidvisitToken(com.puppycrawl.tools.checkstyle.api.DetailAST methodDefToken)-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck
beginTree, clearViolations, destroy, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
-
-
-
Field Detail
-
MSG_KEY_MISSED_TRY_FINALLY
public static final String MSG_KEY_MISSED_TRY_FINALLY
The key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
-
MSG_KEY_PUBLIC_FINALIZE
public static final String MSG_KEY_PUBLIC_FINALIZE
The key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
-
MSG_KEY_USELESS_FINALIZE
public static final String MSG_KEY_USELESS_FINALIZE
The key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
-
MSG_KEY_MISSED_SUPER_FINALIZE_CALL
public static final String MSG_KEY_MISSED_SUPER_FINALIZE_CALL
The key is pointing to the warning message text in "messages.properties" file.- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefaultTokens
public int[] getDefaultTokens()
- Specified by:
getDefaultTokensin classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getAcceptableTokens
public int[] getAcceptableTokens()
- Specified by:
getAcceptableTokensin classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
getRequiredTokens
public int[] getRequiredTokens()
- Specified by:
getRequiredTokensin classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
visitToken
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST methodDefToken)
- Overrides:
visitTokenin classcom.puppycrawl.tools.checkstyle.api.AbstractCheck
-
-