8198372: API to create a SelectableChannel to a FileDescriptor

Alan Bateman Alan.Bateman at oracle.com
Wed Jun 20 13:41:26 UTC 2018

On 20/06/2018 14:16, David Lloyd wrote:
> A few comments...
> +    public interface SelectableChannelCloser {
> I wonder if some basic implementation should be provided for this.  I
> can't think of a case where a user would be able to implement this
> interface without native code of some sort (is this the intention?).
If you managing the file descriptor yourself then it means native code, 
so yes, that is the intention.

> :
> I disagree with these security checks.  Nothing in this API allows the
> caller to actually read or write the FD; that would have to be
> provided separately.  Given that each of the checks are relatively
> expensive, IMO they should be deferred to the point where an object is
> constructed that actually has read and/or write capability.
A permission check is needed here. The two permission targets that 
RuntimePermission specifies for file descriptors are readFileDescriptor 
and writeFileDescriptor, it hardly seems worth introducing new targets 
to poll a file descriptor for reading and writing. Or maybe you are 
suggesting an alternative permission check?


More information about the nio-dev mailing list