8216978: Drop support for pre JDK 1.4 SocketImpl implementations

Reviewed-by: chegar, alanb, dfuchs
This commit is contained in:
Michael McMahon 2019-05-02 17:29:10 +01:00
parent 5a496e21d5
commit 70ea5ab6e1
14 changed files with 109 additions and 463 deletions

View file

@ -71,11 +71,6 @@ class ServerSocket implements java.io.Closeable {
*/
private SocketImpl impl;
/**
* Are we using an older SocketImpl?
*/
private boolean oldImpl = false;
/**
* Creates a server socket with a user-specified {@code SocketImpl}.
*
@ -87,7 +82,6 @@ class ServerSocket implements java.io.Closeable {
*/
protected ServerSocket(SocketImpl impl) {
this.impl = impl;
impl.setServerSocket(this);
}
/**
@ -270,36 +264,13 @@ class ServerSocket implements java.io.Closeable {
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<Void>() {
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 +339,7 @@ class ServerSocket implements java.io.Closeable {
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 +693,7 @@ class ServerSocket implements java.io.Closeable {
* @since 1.4
*/
public boolean isBound() {
// Before 1.3 ServerSockets were always bound during creation
return bound || oldImpl;
return bound;
}
/**
@ -866,14 +836,6 @@ class ServerSocket implements java.io.Closeable {
",localport=" + impl.getLocalPort() + "]";
}
void setBound() {
bound = true;
}
void setCreated() {
created = true;
}
/**
* The factory for all server sockets.
*/