A class overrides finalize(), which is deprecated and unreliable
What it finds
protected void finalize() runs at an unknown time after the object becomes unreachable, possibly never, on a thread of the collector's choosing, and slows down collection of every such object. Finalization is deprecated for removal; a Cleaner or try-with-resources releases resources reliably.
From the rule's source, finalize_override.rs.
class Handle { @Override protected void finalize() throws Throwable {tx0 reports: finalize() is overridden release(); } void finalize(int code) {} void release() {}} 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-override" = "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-override] reason="..."tx0 explain tx0/java:finalize-override shows the same in the terminal. Found a false positive? Report it.