JDK-8165641 : Deprecate Object.finalize
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-09-07
  • Updated: 2021-09-10
  • Resolved: 2017-04-05
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 10 JDK 9
10Fixed 9 b165Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8177970 :  
Description
Finalizers are inherently problematic and their use can lead to performance issues, 
deadlocks, hangs, and other problematic behavior. 

Furthermore the timing of finalization is unpredictable with no guarantee that a finalizer will be called. 
Classes whose instances hold non-heap resources should provide a method
to enable explicit release of those resources, and they should also implement 
java.lang.AutoCloseable if appropriate.

The java.lang.ref.Cleaner and java.lang.ref.PhantomReference provide more flexible and 
efficient ways to release resources when an object becomes unreachable.
Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/9289f04ddb54 User: lana Date: 2017-04-12 18:47:13 +0000
12-04-2017

URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/9289f04ddb54 User: rriggs Date: 2017-04-05 14:27:45 +0000
05-04-2017

I've added jdk9-fix-yes to this issue.
04-04-2017

Fix Request Why: Deprecating finalize is a first step to address the problems listed in the description above. What: Deprecate Object.finalize and add @deprecated recommendations Also, deprecate Subclasses overrides of finalize and document And add @ SuppressWarnings where needed Risk: Low - No runtime behavior will be changed; Compiler warnings will be suppressed for references to the finalize method. Testing: Normal build and test for jdk. Webrev: http://cr.openjdk.java.net/~rriggs/webrev-finalize-deprecate-8165641/
31-03-2017

Updated Review thread: http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-March/047017.html
31-03-2017

Review thread: http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-March/046650.html Webrev: http://cr.openjdk.java.net/~rriggs/webrev-finalize-deprecate-8165641/
14-03-2017

For JDK 9, it is proposed to deprecate Object.finalize and methods that override it within the JDK . Compilation warnings will be suppressed on current uses within the JDK. Future work will be to re-mediate or remove uses of finalize.
10-03-2017