8263233: Update java.net and java.nio to use instanceof pattern variable

Reviewed-by: dfuchs, bpb, chegar, michaelm
This commit is contained in:
Patrick Concannon 2021-03-10 11:05:29 +00:00
parent 3fe8a4661c
commit fdd3941121
17 changed files with 39 additions and 73 deletions

View file

@ -611,10 +611,9 @@ public class Socket implements java.io.Closeable {
if (isConnected())
throw new SocketException("already connected");
if (!(endpoint instanceof InetSocketAddress))
if (!(endpoint instanceof InetSocketAddress epoint))
throw new IllegalArgumentException("Unsupported address type");
InetSocketAddress epoint = (InetSocketAddress) endpoint;
InetAddress addr = epoint.getAddress ();
int port = epoint.getPort();
checkAddress(addr, "connect");