finalize() of a subclass does not call super.finalize()
What it finds
A finalize() in a class that extends another class and does not call super.finalize() skips the cleanup of the superclass, which may hold a native resource of its own.
Only classes with an extends clause are reported: the finalize of Object does nothing.
From the rule's source, finalize_without_super.rs.
class Base { protected void finalize() throws Throwable { }} class Native extends Base { @Override protected void finalize() throws Throwable {tx0 reports: finalize() does not call super.finalize() free(); } void free() {}} class Careful extends Base { @Override protected void finalize() throws Throwable { try { free(); } finally { super.finalize(); } } void free() {}} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:finalize-without-super" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:finalize-without-super] reason="..."tx0 explain tx0/java:finalize-without-super shows the same in the terminal. Found a false positive? Report it.