Since Checkstyle 3.2
finalize()
method invokes
super.finalize()
. Does not check native methods, as
they have no possible java defined implementation.
References: How to Handle Java Finalization's Memory-Retention Issues; 10 points on finalize method in Java.
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="SuperFinalize"/> </module> </module>
Example:
class Example1 { protected void finalize() throws Throwable { super.finalize(); // OK, calls super.finalize() } } class InvalidExample { // violation below, 'Method 'finalize' should call 'super.finalize'' protected void finalize() throws Throwable { } }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.coding