JDK-8253568 : Replace and mitigate Object.finalize() uses in JDK libraries
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2017-05-05
  • Updated: 2024-10-31
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.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8283660 :  
Description
Object.finalize was deprecated in JDK 9. Existing uses of finalize in the JDK need to be replaced or removed. In some cases specification changes are necessary. 

Do a survey of open/src/<module> 'finalize()' usage:

java.base/share/classes/java/lang/Enum.java (keep: empty, final)
java.base/share/classes/java/lang/Object.java (keep: empty, compat)
java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java (empty)

java.desktop/macosx/classes/apple/laf/JRSUIControl.java
java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java
java.desktop/macosx/classes/sun/font/CFont.java
java.desktop/macosx/classes/sun/font/CStrike.java
java.desktop/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java
java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
java.desktop/share/classes/com/sun/imageio/plugins/common/SubImageInputStream.java (empty)
java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java (empty)
java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFBaseJPEGCompressor.java
java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFJPEGDecompressor.java
java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFOldJPEGDecompressor.java
java.desktop/share/classes/com/sun/imageio/stream/StreamFinalizer.java
java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java
java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java
java.desktop/share/classes/java/awt/Graphics.java
java.desktop/share/classes/java/awt/PrintJob.java
java.desktop/share/classes/java/awt/color/ICC_Profile.java (empty)
java.desktop/share/classes/java/awt/image/ColorModel.java (empty)
java.desktop/share/classes/java/awt/image/IndexColorModel.java (empty)
java.desktop/share/classes/javax/imageio/spi/ServiceRegistry.java
java.desktop/share/classes/javax/imageio/stream/FileCacheImageInputStream.java (empty)
java.desktop/share/classes/javax/imageio/stream/FileImageInputStream.java (empty)
java.desktop/share/classes/javax/imageio/stream/FileImageOutputStream.java (empty)
java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java
java.desktop/share/classes/javax/imageio/stream/MemoryCacheImageInputStream.java (empty)
java.desktop/share/classes/javax/swing/text/StringContent.java
java.desktop/share/classes/sun/java2d/SunGraphics2D.java (empty)
java.desktop/share/classes/sun/print/PeekGraphics.java (empty)
java.desktop/share/classes/sun/print/PrintJob2D.java
java.desktop/share/classes/sun/print/ProxyGraphics.java (empty)
java.desktop/share/classes/sun/print/ProxyGraphics2D.java (empty)
java.desktop/unix/classes/sun/awt/X11InputMethodBase.java
java.desktop/windows/classes/sun/awt/windows/WInputMethod.java

java.naming/share/classes/com/sun/jndi/ldap/AbstractLdapNamingEnumeration.java
java.naming/share/classes/com/sun/jndi/ldap/LdapClient.java
java.naming/share/classes/com/sun/jndi/ldap/LdapCtx.java
java.naming/share/classes/com/sun/jndi/ldap/sasl/DefaultCallbackHandler.java

java.rmi/share/classes/sun/rmi/log/LogInputStream.java

java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Base.java
java.security.sasl/share/classes/com/sun/security/sasl/PlainClient.java

java.smartcardio/share/classes/sun/security/smartcardio/CardImpl.java

jdk.crypto.mscapi/windows/classes/sun/security/mscapi/CKey.java

jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsClient.java

jdk.naming.rmi/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java
(RegistryContext.finalize() and BindingEnumeration.finalize())

jdk.security.jgss/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java

jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java

Some are awaiting removal of backward compatible work arounds in a appropriate future release.
Comments
Removed jdk.naming.dns/share/classes/com/sun/jndi/dns/DnsContext.java from the list. Its finalizer has been commented out for quite some time.
28-02-2023

java.base/share/classes/java/util/concurrent/Executors.java removed by JDK-83202899.
28-02-2023

java.base/share/classes/sun/net/www/MeteredStream.java finalizer removed by JDK-8297976.
14-12-2022

(sorted the finalizer list in Description)
24-02-2021

I've moved this into the JDK project as an Enhancement since it's pretty much a straightforward though work item. Subtasks can be created for smaller chunks of work as necessary.
24-09-2020

Jira items labeled with "finalizer". https://bugs.openjdk.java.net/issues/?jql=labels%20%3D%20finalizer%20and%20(%20fixVersion%20%3D%2010%20or%20fixVersion%20is%20empty)
02-12-2017