'finalize()' should not be overridden
Reports overriding the Object.finalize()
method.
According to the Object.finalize()
documentation:
Configure the inspection:
Use the Ignore for trivial 'finalize()' implementations option to ignore
finalize()
implementations with an empty method body or a body containing onlyif
statements that have a condition which evaluates tofalse
and is a compile-time constant. For performance reasons it can be beneficial to override a non-trivialfinalize()
with an empty implementation in a subclass. An empty finalfinalize()
implementation can also be used to prevent subclasses from overriding.
Inspection options
Option | Type | Default |
---|---|---|
Ignore for trivial 'finalize()' implementations | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |