File: Finalize.md

package info (click to toggle)
error-prone-java 2.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 23,204 kB
  • sloc: java: 222,992; xml: 1,319; sh: 25; makefile: 7
file content (15 lines) | stat: -rw-r--r-- 595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Do not override `Object.finalize`.

Starting in JDK 18, the method is deprecated for removal, see
[JEP 421: Deprecate Finalization for Removal](https://openjdk.org/jeps/421).

The [Google Java Style Guide ยง6.4][style] states:

> It is extremely rare to override `Object.finalize`.
>
> Tip: Don't do it. If you absolutely must, first read and understand
> [Effective Java Item 8][ej3e-8], "Avoid finalizers and cleaners" very
> carefully, and then don't do it.

[ej3e-8]: https://books.google.com/books?id=BIpDDwAAQBAJ
[style]: https://google.github.io/styleguide/javaguide.html#s6.4-finalizers