JDK-8285872 : JFR: Remove finalize() methods
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: jfr
  • Priority: P3
  • Status: In Progress
  • Resolution: Unresolved
  • Submitted: 2022-04-29
  • Updated: 2022-05-02
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 19
19Unresolved
Description
The RepositoryChunk::finalize() method has been kept since the inception of JFR, before try-with-resources (JDK 7) and Cleaner (JDK 9) existed. The method should be removed now that finalization is deprecated for removal.

RepositoryChunks are reference counted and when a recording is closed, chunks that are not referenced by a recording are removed from the disk repository. Users can get a listing of not closed recordings by invoking FlightRecorder::getRecordings() so they own the lifecycle already. If a user forget to close a recording, the data will be kept in the repository.

ChunkInputStream och ChunkChannel have finalize() methods and increases the reference counter when copying data out from the disk repository. If an IOException happens during file reading, they are closed and the reference counter decreased for the remaining chunks. Finalizers are not needed.
Comments
A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8510 Date: 2022-05-02 22:12:48 +0000
02-05-2022