On Tue, 9 Mar 2021 20:26:19 GMT, Daniel Fuchs <[email protected]> wrote:
>> src/java.base/share/classes/java/net/NetMulticastSocket.java line 219:
>>
>>> 217: if (addr == null)
>>> 218: addr = new InetSocketAddress(0);
>>> 219: if (!(addr instanceof InetSocketAddress epoint))
>>
>> in the context of this type of change the negative logic is a little obtuse
>> or disjoint in the new style variable declaration, and its subsequent use.
>> I'd find it a more natural flow and easier to read with the instanceof
>> pattern prefacing a block in which the variable is used
>> if (addr instanceof InetSocketAddress epoint) {
>> // a block which is using the epoint variable
>> if (epoint.isUnresolved)
>> throw new SocketException("Unresolved address");
>> InetAddress iaddr = epoint.getAddress;
>> etc, etc ...
>> } else {
>> throw new IllegalArgumentException("Unsupported address type!");
>> }
>
> The disadvantage is that it would add another level of braces.
maybe ... I find it would provide an easier flow to code ... an "easy on the
eye" call flow linkage - the variable is declared and then used .... instead
of the disconnect of throwing an exception or non immediate use of the
variable.
but sure, isn't code somewhat idiosyncratic!!
-------------
PR: https://git.openjdk.java.net/jdk/pull/2890