|
SemmleCode Professional comes with a wide range of pre-packaged analyses, from architectural properties and metrics, to statement-level checks for likely bugs and violations of best practice.
Empty Body of Finalizer
This query finds empty finalize() methods. At best, such a method is useless. At worst, it may
prevent finalization from working properly: Unlike a constructor, a finalizer does not implicitly call the
finalizer of the superclass, thus an empty finalizer prevents any finalization logic defined in any of its
superclasses from being executed.
How to Interpret the Query Results
The query flags all such methods and provides a list of all detected occurrences in the results view.
How to Address the Query Results
Determine whether the finalizer could be removed. Alternatively, insert a call to super.finalize()
as the last statement.
Source Code
References
An article on Writing a finalize() Method
|