mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +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
|
@ -45,13 +45,8 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
|
|||
/**
|
||||
* Constructs an empty instance.
|
||||
*/
|
||||
PlainSocketImpl() { }
|
||||
|
||||
/**
|
||||
* Constructs an instance with the given file descriptor.
|
||||
*/
|
||||
PlainSocketImpl(FileDescriptor fd) {
|
||||
this.fd = fd;
|
||||
PlainSocketImpl(boolean isServer) {
|
||||
super(isServer);
|
||||
}
|
||||
|
||||
static final ExtendedSocketOptions extendedOptions =
|
||||
|
@ -90,7 +85,7 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
|
|||
|
||||
protected Set<SocketOption<?>> supportedOptions() {
|
||||
HashSet<SocketOption<?>> options = new HashSet<>(super.supportedOptions());
|
||||
if (getServerSocket() != null) {
|
||||
if (isServer) {
|
||||
options.addAll(ExtendedSocketOptions.serverSocketOptions());
|
||||
} else {
|
||||
options.addAll(ExtendedSocketOptions.clientSocketOptions());
|
||||
|
@ -106,12 +101,16 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
|
|||
try {
|
||||
socketSetOption0(opt, b, val);
|
||||
} catch (SocketException se) {
|
||||
if (socket == null || !socket.isConnected())
|
||||
if (!isConnected)
|
||||
throw se;
|
||||
}
|
||||
}
|
||||
|
||||
native void socketCreate(boolean isServer) throws IOException;
|
||||
void socketCreate(boolean stream) throws IOException {
|
||||
socketCreate(stream, isServer);
|
||||
}
|
||||
|
||||
native void socketCreate(boolean stream, boolean isServer) throws IOException;
|
||||
|
||||
native void socketConnect(InetAddress address, int port, int timeout)
|
||||
throws IOException;
|
||||
|
|
|
@ -43,7 +43,6 @@ jfieldID psi_portID;
|
|||
jfieldID psi_localportID;
|
||||
jfieldID psi_timeoutID;
|
||||
jfieldID psi_trafficClassID;
|
||||
jfieldID psi_serverSocketID;
|
||||
jfieldID psi_fdLockID;
|
||||
jfieldID psi_closePendingID;
|
||||
|
||||
|
@ -128,9 +127,6 @@ Java_java_net_PlainSocketImpl_initProto(JNIEnv *env, jclass cls) {
|
|||
CHECK_NULL(psi_timeoutID);
|
||||
psi_trafficClassID = (*env)->GetFieldID(env, cls, "trafficClass", "I");
|
||||
CHECK_NULL(psi_trafficClassID);
|
||||
psi_serverSocketID = (*env)->GetFieldID(env, cls, "serverSocket",
|
||||
"Ljava/net/ServerSocket;");
|
||||
CHECK_NULL(psi_serverSocketID);
|
||||
psi_fdLockID = (*env)->GetFieldID(env, cls, "fdLock",
|
||||
"Ljava/lang/Object;");
|
||||
CHECK_NULL(psi_fdLockID);
|
||||
|
@ -156,10 +152,10 @@ static jclass socketExceptionCls;
|
|||
/*
|
||||
* Class: java_net_PlainSocketImpl
|
||||
* Method: socketCreate
|
||||
* Signature: (Z)V */
|
||||
* Signature: (ZZ)V */
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
|
||||
jboolean stream) {
|
||||
jboolean stream, jboolean isServer) {
|
||||
jobject fdObj, ssObj;
|
||||
int fd;
|
||||
int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
|
||||
|
@ -204,8 +200,7 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
|
|||
* If this is a server socket then enable SO_REUSEADDR
|
||||
* automatically and set to non blocking.
|
||||
*/
|
||||
ssObj = (*env)->GetObjectField(env, this, psi_serverSocketID);
|
||||
if (ssObj != NULL) {
|
||||
if (isServer) {
|
||||
int arg = 1;
|
||||
SET_NONBLOCKING(fd);
|
||||
if (NET_SetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&arg,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue