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

Brian Burkhalter brian.burkhalter at oracle.com
Fri Sep 1 14:56:43 UTC 2017

Please review at your convenience:


There is a question at line 106 of FileChannelImpl.java which needs to be resolved.

Another question is whether a synchronized block should be used in or around invalidateAndClose() in addition to relying on the pseudo-synchronization of checking the FileDescriptor validity. It is necessary to invalidate the FileDescriptor in any case as otherwise “Bad file descriptor” exceptions occur. This is likely due to the cleaning action attempting to close a native file descriptor which was already closed when the channel was closed.

That this actually works was verified by instrumenting FileChannelImpl$Closer#run() with a print statement which was since removed. The issue has however been labelled “noreg-hard” as there appears to be no way to verify the fix without such instrumentation or via existing public APIs.



More information about the nio-dev mailing list