mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8216978: Drop support for pre JDK 1.4 SocketImpl implementations
Reviewed-by: chegar, alanb, dfuchs
This commit is contained in:
parent
5a496e21d5
commit
70ea5ab6e1
14 changed files with 109 additions and 463 deletions
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue