JEP draft: UNIX Domain Socket Channels

OwnerMichael McMahon
Componentcore-libs / java.nio
Discussionnio dash dev at openjdk dot java dot net
Created2020/02/06 09:45
Updated2020/02/17 11:35


Add UNIX domain (AF_UNIX) socket channels for both connection sockets and listener sockets. Additionally, enhance and expand the inherited channel mechanism, java.nio.channels.SelectorProvider::inheritedChannel, which already has partial and limited support for UNIX domain connection sockets, but only for connection sockets and only as a java.nio.channels.ByteChannel.


Support the standard features of UNIX domain sockets that are implemented across most popular platforms.


It is not a goal to support Linux-specific features, such as the abstract filesystem-independent namespace. It is not a goal to support features that are unsupported on Microsoft Windows such as socket pairs, and peer credentials. Support for these features can be revisited in the future, if needed.


The benefits of this feature are:

UNIX domains sockets are being proposed for the Java SE Platform now, as of recent times there is cross platform support on most popular platforms. More specifically, native support for UNIX domains sockets is available on Microsoft Windows 10 and Microsoft Windows Server 2019.


The proposed API footprint comprises:

The implementation comprises the API change above with additional normative text in the SocketChannel and ServerSocketChannel classes to distinguish UNIX domain channels from the existing IP channel types, together with Java and native code which interfaces with the host OS socket layer.

A prototype exists in order to prove feasibility and validate API aspects. The prototype can be seen in the "unixdomainchannels" branch of the JDK Sandbox development repository.


As mentioned above an alternative approach would be to wait for Panama and to interface to the system API through that mechanism. But, this approach provides integration with existing selectable channels, whereas an independent Panama based solution would not.


Automatic unit tests will be added that exercise the API and implementation. Microsoft Windows 10 and Microsoft Windows Server 2019 are required to test the Windows-specific part of the implementation. Older Windows versions will also be used to check that the lack of support on those versions is handled appropriately. All existing versions of macOS, Solaris, and Linux have native support for UNIX domain sockets and will be utilised for testing.

Risks and Assumptions



This enhancement now depends on the following RFE for SocketChannel and ServerSocketChannel.

This RFE adds the static factory creation methods to SocketChannel and ServerSocketChannel.