Remove the (empty) ThreadPoolExecutor.finalize() method

XMLWordPrintable

    • Type: CSR
    • Resolution: Approved
    • Priority: P4
    • 27
    • Component/s: core-libs
    • None
    • source, behavioral
    • low
    • Object.finalize() throws Throwable, TPE.finalize() overrides and doesn't declare any checked exception. It's possible there is old code that extends TPE and invokes super.finalize() - this may no longer compile.
    • Java API
    • SE

      Summary

      ThreadPoolExecutor.finalize() was (re)specified to do nothing in JDK 11. All finalize methods (along with the finalization mechanism itself) were deprecated for removal with JEP 421 in JDK 18.

      Problem

      The vestigial ThreadPoolExecutor.finalize() method serves no purpose, and recently caused a minor annoyance in test code (JDK-8371682).

      Solution

      The finalizer in ThreadPoolExecutor should be removed.

      There is a small risk that there are existing subclasses of ThreadPoolExecutor that override finalize() to call super.finalize(). Such classes would no longer compile (due to the mismatch between Object.finalize() throwing Throwable, and ThreadPoolExecutor.finalize() not throwing an exception). A Corpus search did not find any such subclass.

      Specification

      The spec change is best viewed in the attached specdiff, as the method spec is generated from verbiage inherited from Object.finalize(), plus local @implNote.

            Assignee:
            Brent Christian
            Reporter:
            Brent Christian
            Alan Bateman
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: