test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java
changeset 59305 219ec11136d9
parent 58313 8a2bc12d2a9a
--- a/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java	Thu Nov 28 12:05:02 2019 +0100
+++ b/test/jdk/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java	Thu Nov 28 12:28:48 2019 +0000
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -91,7 +92,7 @@
      */
     public static SocketChannel launchWithSocketChannel(String className, String options[], String args[]) throws IOException {
         ServerSocketChannel ssc = ServerSocketChannel.open();
-        ssc.socket().bind(new InetSocketAddress(0));
+        ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(), 0));
         InetSocketAddress isa = new InetSocketAddress(InetAddress.getLocalHost(),
                                                       ssc.socket().getLocalPort());
         SocketChannel sc1 = SocketChannel.open(isa);
@@ -120,7 +121,7 @@
         throws IOException
     {
         ServerSocketChannel ssc = ServerSocketChannel.open();
-        ssc.socket().bind(new InetSocketAddress(0));
+        ssc.socket().bind(new InetSocketAddress(InetAddress.getLocalHost(), 0));
         int port = ssc.socket().getLocalPort();
         launch(className, options, args, Util.getFD(ssc));
         ssc.close();
@@ -147,18 +148,18 @@
     public static DatagramChannel launchWithDatagramChannel(String className, String options[], String args[])
         throws IOException
     {
+        InetAddress address = InetAddress.getLocalHost();
+        if (address.isLoopbackAddress()) {
+            address = InetAddress.getLoopbackAddress();
+        }
         DatagramChannel dc = DatagramChannel.open();
-        dc.socket().bind(new InetSocketAddress(0));
+        dc.socket().bind(new InetSocketAddress(address, 0));
 
         int port = dc.socket().getLocalPort();
         launch(className, options, args, Util.getFD(dc));
         dc.close();
 
         dc = DatagramChannel.open();
-        InetAddress address = InetAddress.getLocalHost();
-        if (address.isLoopbackAddress()) {
-            address = InetAddress.getLoopbackAddress();
-        }
         InetSocketAddress isa = new InetSocketAddress(address, port);
 
         dc.connect(isa);