8216984: Deprecate for removal Socket constructors to create UDP sockets

Reviewed-by: alanb, dfuchs
This commit is contained in:
Jaikiran Pai 2024-05-30 10:03:06 +00:00
parent 3cff588a31
commit 1b04f6487c
2 changed files with 10 additions and 5 deletions

View file

@ -486,9 +486,9 @@ public class Socket implements java.io.Closeable {
* the specified range of valid port values, which is between * the specified range of valid port values, which is between
* 0 and 65535, inclusive. * 0 and 65535, inclusive.
* @see SecurityManager#checkConnect * @see SecurityManager#checkConnect
* @deprecated Use DatagramSocket instead for UDP transport. * @deprecated Use {@link DatagramSocket} instead for UDP transport.
*/ */
@Deprecated @Deprecated(forRemoval = true, since = "1.1")
@SuppressWarnings("this-escape") @SuppressWarnings("this-escape")
public Socket(String host, int port, boolean stream) throws IOException { public Socket(String host, int port, boolean stream) throws IOException {
this(host != null ? new InetSocketAddress(host, port) : this(host != null ? new InetSocketAddress(host, port) :
@ -529,9 +529,9 @@ public class Socket implements java.io.Closeable {
* 0 and 65535, inclusive. * 0 and 65535, inclusive.
* @throws NullPointerException if {@code host} is null. * @throws NullPointerException if {@code host} is null.
* @see SecurityManager#checkConnect * @see SecurityManager#checkConnect
* @deprecated Use DatagramSocket instead for UDP transport. * @deprecated Use {@link DatagramSocket} instead for UDP transport.
*/ */
@Deprecated @Deprecated(forRemoval = true, since = "1.1")
@SuppressWarnings("this-escape") @SuppressWarnings("this-escape")
public Socket(InetAddress host, int port, boolean stream) throws IOException { public Socket(InetAddress host, int port, boolean stream) throws IOException {
this(host != null ? new InetSocketAddress(host, port) : null, this(host != null ? new InetSocketAddress(host, port) : null,

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -80,6 +80,11 @@ public abstract class SocketImpl implements SocketOptions {
/** /**
* Creates either a stream or a datagram socket. * Creates either a stream or a datagram socket.
* *
* @apiNote
* The {@link Socket} constructors to create a datagram socket
* are deprecated for removal. This method will be re-specified
* in a future release to not support creating datagram sockets.
*
* @param stream if {@code true}, create a stream socket; * @param stream if {@code true}, create a stream socket;
* otherwise, create a datagram socket. * otherwise, create a datagram socket.
* @throws IOException if an I/O error occurs while creating the * @throws IOException if an I/O error occurs while creating the