JDK-4192722 : java.io.{FileWriter,OutputStreamWriter} should override finalize to call close
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 1998-11-25
  • Updated: 1998-12-16
  • Resolved: 1998-12-16
Related Reports
Relates :  
Relates :  

Name: gsC80088			Date: 11/24/98

In the same way as the -Stream classes, and the File class, the classes FileWriter and OutputStreamWriter (and the corresponding -Reader classes) should override finalize() to ensure that the stream is always closed when the object is finalized.

I haven't really looked into it, but the easiest way to do this might be to have their base class, Writer, provide a default implementation of finalize() which calls close().
(Review ID: 43330)

EVALUATION Will not fix. Finalization should not be used to manage finite resources external to the Java heap. Making this change to existing classes also risks breaking binary compatibility. -- mr@eng 1998/12/16