Do not override
Starting in JDK 18, the method is deprecated for removal, see JEP 421: Deprecate Finalization for Removal.
The Google Java Style Guide §6.4 states:
It is extremely rare to override
Tip: Don’t do it. If you absolutely must, first read and understand Effective Java Item 8, “Avoid finalizers and cleaners” very carefully, and then don’t do it.
Suppress false positives by adding the suppression annotation to the enclosing element:
@SuppressWarnings("Finalize") // TODO(user): remove overrides of finalize
Suppress false positives by adding the suppression annotation
@SuppressWarnings("Finalize") to the enclosing element.