Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8235139: Deprecate the socket impl factory mechanism #2375

Closed
wants to merge 9 commits into from
13 changes: 12 additions & 1 deletion src/java.base/share/classes/java/net/DatagramSocket.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -946,7 +946,18 @@ public DatagramChannel getChannel() {
* @see java.net.DatagramSocketImplFactory#createDatagramSocketImpl()
* @see SecurityManager#checkSetFactory
* @since 1.3
*
* @deprecated Use {@link DatagramChannel}, or subclass {@code DatagramSocket}
* directly.
* <br> This method provided a way in early JDK releases to replace the
* system wide implementation of {@code DatagramSocket}. It has been mostly
* obsolete since Java 1.4. If required, a {@code DatagramSocket} can be
* created to use a custom implementation by extending {@code DatagramSocket}
* and using the {@linkplain #DatagramSocket(DatagramSocketImpl) protected
* constructor} that takes an {@linkplain DatagramSocketImpl implementation}
* as a parameter.
pconcannon marked this conversation as resolved.
Show resolved Hide resolved
*/
@Deprecated(since = "17")
public static synchronized void
setDatagramSocketImplFactory(DatagramSocketImplFactory fac)
throws IOException
Expand Down
22 changes: 12 additions & 10 deletions src/java.base/share/classes/java/net/ServerSocket.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -41,10 +41,7 @@
* based on that request, and then possibly returns a result to the requester.
* <p>
* The actual work of the server socket is performed by an instance
* of the {@code SocketImpl} class. An application can
* change the socket factory that creates the socket
* implementation to configure itself to create sockets
* appropriate to the local firewall.
* of the {@code SocketImpl} class.
*
* <p> The {@code ServerSocket} class defines convenience
* methods to set and get several socket options. This class also
Expand Down Expand Up @@ -76,7 +73,6 @@
* Additional (implementation specific) options may also be supported.
*
* @see java.net.SocketImpl
* @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory)
* @see java.nio.channels.ServerSocketChannel
* @since 1.0
*/
Expand Down Expand Up @@ -164,8 +160,6 @@ public ServerSocket() throws IOException {
* 0 and 65535, inclusive.
*
* @see java.net.SocketImpl
* @see java.net.SocketImplFactory#createSocketImpl()
* @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory)
* @see SecurityManager#checkListen
*/
public ServerSocket(int port) throws IOException {
Expand Down Expand Up @@ -217,8 +211,6 @@ public ServerSocket(int port) throws IOException {
* 0 and 65535, inclusive.
*
* @see java.net.SocketImpl
* @see java.net.SocketImplFactory#createSocketImpl()
* @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory)
* @see SecurityManager#checkListen
*/
public ServerSocket(int port, int backlog) throws IOException {
Expand Down Expand Up @@ -929,7 +921,17 @@ public String toString() {
* {@code checkSetFactory} method doesn't allow the operation.
* @see java.net.SocketImplFactory#createSocketImpl()
* @see SecurityManager#checkSetFactory
* @deprecated Use {@link ServerSocketChannel}, or subclass {@code ServerSocket}
* directly.
pconcannon marked this conversation as resolved.
Show resolved Hide resolved
* <br> This method provided a way in early JDK releases to replace the
* system wide implementation of {@code ServerSocket}. It has been mostly
* obsolete since Java 1.4. If required, a {@code ServerSocket} can be
* created to use a custom implementation by extending {@code ServerSocket}
* and using the {@linkplain #ServerSocket(SocketImpl) protected
* constructor} that takes an {@linkplain SocketImpl implementation}
* as a parameter.
*/
@Deprecated(since = "17")
public static synchronized void setSocketFactory(SocketImplFactory fac) throws IOException {
if (factory != null) {
throw new SocketException("factory already defined");
Expand Down
30 changes: 13 additions & 17 deletions src/java.base/share/classes/java/net/Socket.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,8 +33,6 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.nio.channels.SocketChannel;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Objects;
import java.util.Set;
import java.util.Collections;
Expand All @@ -45,10 +43,7 @@
* between two machines.
* <p>
* The actual work of the socket is performed by an instance of the
* {@code SocketImpl} class. An application, by changing
* the socket factory that creates the socket implementation,
* can configure itself to create sockets appropriate to the local
* firewall.
* {@code SocketImpl} class.
*
* <p> The {@code Socket} class defines convenience
* methods to set and get several socket options. This class also
Expand Down Expand Up @@ -96,7 +91,6 @@
* </blockquote>
* Additional (implementation specific) options may also be supported.
*
* @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)
* @see java.net.SocketImpl
* @see java.nio.channels.SocketChannel
* @since 1.0
Expand Down Expand Up @@ -282,9 +276,7 @@ private static Void checkPermission(SocketImpl impl) {
* @throws IllegalArgumentException if the port parameter is outside
* the specified range of valid port values, which is between
* 0 and 65535, inclusive.
* @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)
* @see java.net.SocketImpl
* @see java.net.SocketImplFactory#createSocketImpl()
* @see SecurityManager#checkConnect
*/
public Socket(String host, int port)
Expand Down Expand Up @@ -318,9 +310,7 @@ public Socket(String host, int port)
* the specified range of valid port values, which is between
* 0 and 65535, inclusive.
* @throws NullPointerException if {@code address} is null.
* @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)
* @see java.net.SocketImpl
* @see java.net.SocketImplFactory#createSocketImpl()
* @see SecurityManager#checkConnect
*/
public Socket(InetAddress address, int port) throws IOException {
Expand Down Expand Up @@ -448,9 +438,7 @@ public Socket(InetAddress address, int port, InetAddress localAddr,
* @throws IllegalArgumentException if the port parameter is outside
* the specified range of valid port values, which is between
* 0 and 65535, inclusive.
* @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)
* @see java.net.SocketImpl
* @see java.net.SocketImplFactory#createSocketImpl()
* @see SecurityManager#checkConnect
* @deprecated Use DatagramSocket instead for UDP transport.
*/
Expand Down Expand Up @@ -492,9 +480,7 @@ public Socket(String host, int port, boolean stream) throws IOException {
* the specified range of valid port values, which is between
* 0 and 65535, inclusive.
* @throws NullPointerException if {@code host} is null.
* @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)
* @see java.net.SocketImpl
* @see java.net.SocketImplFactory#createSocketImpl()
* @see SecurityManager#checkConnect
* @deprecated Use DatagramSocket instead for UDP transport.
*/
Expand Down Expand Up @@ -1761,7 +1747,17 @@ static SocketImplFactory socketImplFactory() {
* {@code checkSetFactory} method doesn't allow the operation.
* @see java.net.SocketImplFactory#createSocketImpl()
* @see SecurityManager#checkSetFactory
*/
* @deprecated Use {@link SocketChannel}, or subclass {@code Socket}
* directly.
pconcannon marked this conversation as resolved.
Show resolved Hide resolved
* <br> This method provided a way in early JDK releases to replace the
* system wide implementation of {@code Socket}. It has been mostly
* obsolete since Java 1.4. If required, a {@code Socket} can be
* created to use a custom implementation by extending {@code Socket}
* and using the {@linkplain #Socket(SocketImpl) protected
* constructor} that takes an {@linkplain SocketImpl implementation}
* as a parameter.
*/
@Deprecated(since = "17")
public static synchronized void setSocketImplFactory(SocketImplFactory fac)
throws IOException
{
Expand Down