jdk/test/com/sun/jdi/OptionTest.java
changeset 4514 7758bdd54629
parent 2 90ce3da70b43
child 5506 202f599c92aa
--- a/jdk/test/com/sun/jdi/OptionTest.java	Tue Dec 08 12:41:01 2009 -0800
+++ b/jdk/test/com/sun/jdi/OptionTest.java	Wed Dec 09 09:46:57 2009 -0800
@@ -32,6 +32,9 @@
  *  @run compile -g VMConnection.java
  *  @run main/othervm OptionTest
  */
+
+import java.net.ServerSocket;
+
 public class OptionTest extends Object {
     private Process subprocess;
     private int subprocessStatus;
@@ -122,12 +125,18 @@
     }
 
     public static void main(String[] args) throws Exception {
+        // find a free port
+        ServerSocket ss = new ServerSocket(0);
+        int port = ss.getLocalPort();
+        ss.close();
+        String address = String.valueOf(port);
+
         String javaExe = System.getProperty("java.home") +
             java.io.File.separator + "bin" +
             java.io.File.separator + "java";
         String targetClass = "HelloWorld";
         String baseOptions = "transport=dt_socket" +
-                              ",address=8000" +
+                              ",address=" + address +
                               ",server=y" +
                               ",suspend=n";