RFR 8080225: FileInputStream cleanup should be improved

Roger Riggs Roger.Riggs at Oracle.com
Sat Sep 30 15:55:32 UTC 2017

Hi Bernd,

The reachabilityFence only ensures that the local variable 'ref' is not 
deemed to be out of scope  by the hotspot compiler.
The value of 'raf' is set to null before the gc is triggered (usually) 
on the first iteration of the loop.

I'll add a comment.

Regards, Roger

On 9/30/2017 12:34 AM, Bernd Eckenfels wrote:
> Hello,
> if UnreferencedRAFClosesFd.java is supposed to test the behavior of 
> unreachable ˋrafˋ I wonder how it works as it hold on raf with a 
> reachabilityFence at the end of the main method? Maybe that asks for 
> an explanative comment?
> Gruss
> Bernd
> -- 
> http://bernd.eckenfels.net
> ------------------------------------------------------------------------
> *From:* core-libs-dev <core-libs-dev-bounces at openjdk.java.net> on 
> behalf of Roger Riggs <Roger.Riggs at Oracle.com>
> *Sent:* Friday, September 29, 2017 7:17:34 PM
> *To:* Core-Libs-Dev
> *Subject:* RFR 8080225: FileInputStream cleanup should be improved
> Replacing finalizers in FileInputStream, FileOutputStream, and adding
> cleanup to RandomAccessFile
> and NIO File Channels with Cleaner based implementations required
> changes to FileDescriptor.
> The specification of FileInputStream and FileOutputStream is changed to
> remove the finalizer
> behavior that required their respective close methods to be called.
> This change to the behavior is tracked with CSR 8187325 [3].
> The FileDescriptor implementations (Unix and Windows) provide a cleanup
> function that is now used by
> FIS, FOS, RAF, and async and normal FileChannels.  Each requests
> FileDescriptor to register a cleanup function
> when the fd or handle is assigned and delegates to
> FileDescriptor.close.  If the respective
> FileDescriptor.close method is not called, the fd or handle will be
> closed when the FileDescriptor
> is determined to be phantom reachable.
> The other uses of FileDescriptor are not intended to be changed, for
> example in sockets and datagrams.
> Some tests were modified to not rely on finalization; new tests are
> provided.
> Comments are appreciated on both the CSR [3] and the implementation [1].
> [1] webrev: 
> http://cr.openjdk.java.net/~rriggs/webrev-fis-cleanup-8080225/ 
> <http://cr.openjdk.java.net/%7Erriggs/webrev-fis-cleanup-8080225/>
> [2] Issue: https://bugs.openjdk.java.net/browse/JDK-8080225
> [3] CSR:  8187325  FileInputStream/FileOutputStream should use the
> Cleaner instead of finalize
> https://bugs.openjdk.java.net/browse/JDK-8187325
> Thanks, Roger

More information about the core-libs-dev mailing list