JDK-8266936 : Add a finalization JFR event
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: jfr
  • Affected Version: 17
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-05-11
  • Updated: 2022-12-07
  • Resolved: 2021-10-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 b20Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8276079 :  
Description
Use of finalizers has long been discouraged, in favor of other resource management techniques such as try-with-resources and java.lang.ref.Cleaner.  Object.finalize() was deprecated in Java 9 (JDK-8165641).

A JFR event, either generated whenever a finalizer is called, or by some alternative means to detect what code is still using finalizers would be helpful.

Comments
[~coffeys] Yes the "finalizer" log tag was added. The VM's unified logging tags are not explicitly documented and are subject to change. The set of available tags for a VM are shown by "java -Xlog:help"
07-12-2022

The -Xlog:finalizer option became available via this enhancement also. Doesn't seem to be documented anywhere.
06-12-2022

To clarify: JEP 421 (https://openjdk.java.net/jeps/421) deprecated the finalization mechanism for eventual removal. However no specific date or JDK release has been set for when finalization will be disabled-by-default, or removed.
19-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk17u-dev/pull/351 Date: 2022-04-19 15:06:41 +0000
19-04-2022

[17u] Fix request I would like to ask for a consideration of backporting this new event to JDK 17u. Although I know that typically new JFR events are not backported in this case I think an exception could be made - the reasoning is that finalizers are to be removed in the next LTS release and it would be helpful for the users of the current LTS release to be able to get extra notification via the JFR event. While one might argue that the users should be running the latest available JDK this is not true in real life and many users will just stick with the LTS until the next LTS is released (and usually even few update releases - to 'let things bake'). The changes apply almost cleanly - the only merge conflict was in `mutexLock.cpp` where the JDK17u version already contains the expected change. JTReg tests for tier1, tier2 and jdk_jfr are passing.
19-04-2022

Changeset: 72a976ef Author: Markus Grönlund <mgronlun@openjdk.org> Date: 2021-10-18 16:52:36 +0000 URL: https://git.openjdk.java.net/jdk/commit/72a976ef05fc2c62657920a560a0abc60b27c852
18-10-2021