On Sun, 13 Sep 2026 11:33:40 GMT, Lee Jiwon <[email protected]> wrote:
>> src/jdk.net/share/classes/jdk/net/Sockets.java line 334:
>>
>>> 332: }
>>> 333: if (Net.isServerSocketIPTosEnabled()) {
>>> 334: set.add(StandardSocketOptions.IP_TOS);
>>
>> I would be tempted to just replace this method with something like the
>> following. This would avoid the duplicate and avoids it getting out of sync
>> with what each socket type supports.
>>
>> private static Map<Class<?>, Set<SocketOption<?>>> optionSets() {
>> var map = new HashMap<Class<?>, Set<SocketOption<?>>>();
>> try (var s = new Socket()) {
>> map.put(Socket.class, s.supportedOptions());
>> } catch (IOException e) {
>> throw new IOError(e);
>> }
>> try (var s = new ServerSocket()) {
>> map.put(ServerSocket.class, s.supportedOptions());
>> } catch (IOException e) {
>> throw new IOError(e);
>> }
>> try (var s = new DatagramSocket()) {
>> map.put(DatagramSocket.class, s.supportedOptions());
>> } catch (IOException e) {
>> throw new IOError(e);
>> }
>> try (var s = new MulticastSocket(null)) {
>> map.put(MulticastSocket.class, s.supportedOptions());
>> } catch (IOException e) {
>> throw new IOError(e);
>> }
>> return Map.copyOf(map);
>> }
>
> On macOS/aarch64, deriving the sets from socket instances adds five options
> for `DatagramSocket` (`IP_DONTFRAGMENT`, `SO_BROADCAST`, and the three
> `IP_MULTICAST_*` options), and two for `MulticastSocket` (`IP_DONTFRAGMENT`
> and `SO_BROADCAST`).
>
> Should I include these changes in this PR and update the CSR, or derive only
> the `ServerSocket` set here and handle the others separately?
Right, the (depreacted) jdk.net.Sockets.supportedOptions method has a hardcoded
lists of options that is out of date. The spec for these method allows the set
to include non-standard sockets options. So yes, a side effect is that it
"fixes" the issue.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/32808#discussion_r3999840957