JDK 10 RFR of 8147615: (fc) FileChannelImpl has no finalizer

Brian Burkhalter brian.burkhalter at oracle.com
Mon Oct 9 19:03:38 UTC 2017


OK, here’s a version which is not brain-dead:

http://cr.openjdk.java.net/~bpb/8147615/webrev.03/

I should not that the test passes without using a final local FileDescriptor variable:

--- a/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
+++ b/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java
@@ -101,9 +101,8 @@
         this.nd = new FileDispatcherImpl();
         // Register a cleaning action if and only if there is no parent
         // as the parent will take care of closing the file descriptor.
-        final FileDescriptor fdl = fd;
         this.cleanable = parent != null ? null :
-            CleanerFactory.cleaner().register(this, () -> fdAccess.close(fdl));
+            CleanerFactory.cleaner().register(this, () -> fdAccess.close(fd));

Thanks,

Brian

On Oct 9, 2017, at 8:53 AM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:

> That’s what I get for attempting to fool with it on a Saturday morning.
> 
> On Oct 9, 2017, at 6:48 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
>> This just creates a Cleanable that invokes close, you are looking for:
>>     cleaner.register(this, () -> fdAccess.close(fd));
>> 
>> Once you remove this inner class then you could rename cleanable to "closer" to make it more readable.
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20171009/ac3775bd/attachment-0001.html>


More information about the nio-dev mailing list