Inspectopedia Help

'finalize()' should not be overridden

Reports overriding the Object.finalize() method.

According to the Object.finalize() documentation:

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

Finalize
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Finalization

Configure the inspection:

  • Use the Ignore for trivial 'finalize()' implementations option to ignore finalize() implementations with an empty method body or a body containing only if statements that have a condition which evaluates to false and is a compile-time constant. For performance reasons it can be beneficial to override a non-trivial finalize() with an empty implementation in a subclass. An empty final finalize() implementation can also be used to prevent subclasses from overriding.

Inspection options

Here you can find the description of settings available for the 'finalize()' should not be overridden inspection, and the reference of their default values.

Ignore for trivial 'finalize()' implementations

Default: Selected

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Java, 241.18072

Last modified: 18 June 2024