--- old/src/java.base/share/classes/java/net/ServerSocket.java 2019-04-18 10:58:16.000000000 +0100 +++ new/src/java.base/share/classes/java/net/ServerSocket.java 2019-04-18 10:58:15.000000000 +0100 @@ -30,8 +30,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.nio.channels.ServerSocketChannel; -import java.security.AccessController; -import java.security.PrivilegedExceptionAction; import java.util.Set; import java.util.Collections; @@ -72,11 +70,6 @@ private SocketImpl impl; /** - * Are we using an older SocketImpl? - */ - private boolean oldImpl = false; - - /** * Creates a server socket with a user-specified {@code SocketImpl}. * * @param impl an instance of a SocketImpl to use on the ServerSocket. @@ -87,7 +80,6 @@ */ protected ServerSocket(SocketImpl impl) { this.impl = impl; - impl.setServerSocket(this); } /** @@ -270,36 +262,13 @@ return impl; } - private void checkOldImpl() { - if (impl == null) - return; - // SocketImpl.connect() is a protected method, therefore we need to use - // getDeclaredMethod, therefore we need permission to access the member - try { - AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Void run() throws NoSuchMethodException { - impl.getClass().getDeclaredMethod("connect", - SocketAddress.class, - int.class); - return null; - } - }); - } catch (java.security.PrivilegedActionException e) { - oldImpl = true; - } - } - private void setImpl() { SocketImplFactory factory = ServerSocket.factory; if (factory != null) { impl = factory.createSocketImpl(); - checkOldImpl(); } else { impl = SocketImpl.createPlatformSocketImpl(true); } - if (impl != null) - impl.setServerSocket(this); } /** @@ -368,7 +337,7 @@ public void bind(SocketAddress endpoint, int backlog) throws IOException { if (isClosed()) throw new SocketException("Socket is closed"); - if (!oldImpl && isBound()) + if (isBound()) throw new SocketException("Already bound"); if (endpoint == null) endpoint = new InetSocketAddress(0); @@ -722,8 +691,7 @@ * @since 1.4 */ public boolean isBound() { - // Before 1.3 ServerSockets were always bound during creation - return bound || oldImpl; + return bound; } /** @@ -863,14 +831,6 @@ ",localport=" + impl.getLocalPort() + "]"; } - void setBound() { - bound = true; - } - - void setCreated() { - created = true; - } - /** * The factory for all server sockets. */