--- old/src/java.base/share/classes/java/net/ServerSocket.java 2018-05-03 16:52:22.375492904 -0700 +++ new/src/java.base/share/classes/java/net/ServerSocket.java 2018-05-03 16:52:22.165492918 -0700 @@ -76,10 +76,11 @@ private boolean oldImpl = false; /** - * Package-private constructor to create a ServerSocket associated with - * the given SocketImpl. + * Creates a server socket with a user-specified SocketImpl. + * + * @param impl the user-specified SocketImpl */ - ServerSocket(SocketImpl impl) { + protected ServerSocket(SocketImpl impl) { this.impl = impl; impl.setServerSocket(this); } @@ -515,7 +516,20 @@ throw new SocketException("Socket is closed"); if (!isBound()) throw new SocketException("Socket is not bound yet"); - Socket s = new Socket((SocketImpl) null); + + Socket s = null; + Class cls = impl.getClass(); + if (cls.getName().contains("RdmaSocketImpl")) { + try { + Constructor c = cls.getConstructor(); + s = new Socket((SocketImpl)c.newInstance()); + } catch (NoSuchMethodException | InstantiationException | + IllegalAccessException | InvocationTargetException e) { + throw new AssertionError(e); + } + } else { + s = new Socket((SocketImpl) null); + } implAccept(s); return s; } @@ -546,8 +560,8 @@ } si = s.impl; s.impl = null; - si.address = new InetAddress(); - si.fd = new FileDescriptor(); + si.setAddress(new InetAddress()); + si.setFileDescriptor(new FileDescriptor()); getImpl().accept(si); SocketCleanable.register(si.fd); // raw fd has been set