RFR: 8263903: Use Cleaner instead of finalize to auto stop Timer thread

Kim Barrett kbarrett at openjdk.java.net
Sun Mar 21 04:00:07 UTC 2021


Please review this change to java.util.Timer, replacing the use of deprecated finalization-based cleanup with use of java.lang.ref.Cleaner.

In addition, Timer.cancel now cancels any later execution of the the no longer relevant cleanup.

Testing:
mach5 tier1
New AutoStop test verifies the specified cleanup behavior.
(There are existing tests involving Timer.cancel.)

-------------

Commit messages:
 - Use cleaner instead of finalize to auto stop Timer thread

Changes: https://git.openjdk.java.net/jdk/pull/3106/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3106&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263903
  Stats: 110 lines in 2 files changed: 96 ins; 3 del; 11 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3106.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3106/head:pull/3106

PR: https://git.openjdk.java.net/jdk/pull/3106


More information about the core-libs-dev mailing list