RFR: 8356154: Respecify java.net.Socket constructors that allow creating UDP sockets to throw IllegalArgumentException [v4]

Alan Bateman alanb at openjdk.org
Tue May 6 06:35:18 UTC 2025


On Mon, 5 May 2025 14:18:26 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Can I please get a review of this change which proposes to respecify the 2 `java.net.Socket` constructors that allow construction of UDP sockets? This addresses https://bugs.openjdk.org/browse/JDK-8356154.
>> 
>> As noted in that JBS issue, in Java 23 we deprecated for removal the 2 `Socket` constructors that allowed UDP socket creation. The plan continues to be to remove those constructors. Before removing those, in order to allow for applications to notice this deprecation, these constructors are now being respecified to throw an `IllegalArgumentException` when the `stream` parameter is `false`.
>> 
>> I will create a CSR once we settle on these changes.
>> 
>> tier1 through tier8 tests have been run with this change and no related failures have been noticed.
>
> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   additional changes to SocketImpl.create(...) API javadoc based on review suggestions

src/java.base/share/classes/java/net/Socket.java line 394:

> 392:      * @param      host     the host name, or {@code null} for the loopback address.
> 393:      * @param      port     the port number.
> 394:      * @param      stream   a {@code boolean} indicating whether this is

I think the parameter description has to be changed as it no longer indicates if the socket is a stream or datatgram socket. I think you can replace with something simple, like must be true, false is not allowed.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25031#discussion_r2074809933


More information about the nio-dev mailing list