Skip to content

Conversation

@bchristi-git
Copy link
Member

@bchristi-git bchristi-git commented Nov 13, 2025

From the bug report:
Prior to JDK 11, ThreadPoolExecutor.finalize() was specified to
"[invoke] shutdown() when this executor is no longer referenced and it has no threads."

In JDK 11, ThreadPoolExecutor.finalize() was re-specified to do nothing, leaving the finalize() method empty. (JDK-8190324).

In JDK 18, finalize() was deprecated for removal (JDK-8276447), after first being "standard" deprecated in JDK 9 (JDK-8165641).

The finalize() method can safely be removed from ThreadPoolExecutor.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8371856 to be approved

Issues

  • JDK-8371748: Remove the (empty) ThreadPoolExecutor.finalize() method (Sub-task - P4)
  • JDK-8371856: Remove the (empty) ThreadPoolExecutor.finalize() method (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28311/head:pull/28311
$ git checkout pull/28311

Update a local copy of the PR:
$ git checkout pull/28311
$ git pull https://git.openjdk.org/jdk.git pull/28311/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28311

View PR using the GUI difftool:
$ git pr show -t 28311

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28311.diff

Using Webrev

Link to Webrev Comment

@bchristi-git
Copy link
Member Author

/csr

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 13, 2025

👋 Welcome back bchristi! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 13, 2025

@bchristi-git This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Nov 13, 2025
@openjdk
Copy link

openjdk bot commented Nov 13, 2025

@bchristi-git an approved CSR request is already required for this pull request.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Nov 13, 2025
@openjdk
Copy link

openjdk bot commented Nov 13, 2025

@bchristi-git The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 13, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 13, 2025

Webrevs

Copy link
Contributor

@viktorklang-ora viktorklang-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bchristi-git!

@jaikiran
Copy link
Member

The failures in the GitHub actions job appear related:

/home/runner/work/jdk/jdk/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java:2011: error: unreported exception Throwable; must be caught or declared to be thrown
                super.finalize();
                              ^

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Nov 14, 2025
@bchristi-git
Copy link
Member Author

The failures in the GitHub actions job appear related:

/home/runner/work/jdk/jdk/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java:2011: error: unreported exception Throwable; must be caught or declared to be thrown
                super.finalize();
                              ^

Indeed.
My understanding is that that is being handled by JDK-8371682.

@bchristi-git
Copy link
Member Author

Thank you, reviewers. :)
Can I also get a review on the CSR? TIA.

@AlanBateman
Copy link
Contributor

Indeed. My understanding is that that is being handled by JDK-8371682.

It might make more sense for this PR to remove testFinalizeMethodCallsSuperFinalize as it's part of the removal.

@sendaoYan
Copy link
Member

Indeed. My understanding is that that is being handled by JDK-8371682.

It might make more sense for this PR to remove testFinalizeMethodCallsSuperFinalize as it's part of the removal.

Should I close #28278 as duplicated to this PR.

@ExE-Boss
Copy link

Wrt. the CSR’s “Compatibility Risk Description”:

Subclasses that @⁠Override finalize, call super.finalize() or call finalize() directly will continue to compile and execute.

This isn’t completely correct, as super.finalize() will now have throws Throwable, where it previously didn’t, causing a source incompatibility, as seen in ThreadPoolExecutorSubclassTest:

/home/runner/work/jdk/jdk/test/jdk/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java:2011:
error: unreported exception Throwable; must be caught or declared to be thrown
                super.finalize();
                              ^

@AlanBateman
Copy link
Contributor

AlanBateman commented Nov 17, 2025

super.finalize() will now have throws Throwable, where it previously didn’t, causing a source incompatibility, as seen in ThreadPoolExecutorSubclassTest:

Indeed, there is a source compatibility issue here. @bchristi-git Have you done corpus searches yet to see if there are cases that extend TPE and invoke super.finalize? It wouldn't any in code written in recent years, but maybe older code that needs updating. The overall risk here is low though and the migration would be to just drop the super.finalize() as it doesn't do anything since JDK 11.

@sendaoYan
Copy link
Member

@bchristi-git I have integrated #28278, I think you should merge the master to fix the GHA test failures.

@openjdk openjdk bot added csr Pull request needs approved CSR before integration and removed ready Pull request is ready to be integrated labels Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org csr Pull request needs approved CSR before integration rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

6 participants