test/com/sun/jdi/OptionTest.java
Print this page
@@ -30,10 +30,13 @@
* @run compile -g OptionTest.java
* @run compile -g HelloWorld.java
* @run compile -g VMConnection.java
* @run main/othervm OptionTest
*/
+
+import java.net.ServerSocket;
+
public class OptionTest extends Object {
private Process subprocess;
private int subprocessStatus;
private static final String CR = System.getProperty("line.separator");
private static final int BUFFERSIZE = 4096;
@@ -120,16 +123,22 @@
return result;
}
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";
/* Option combinations to try (combos faster, fewer exec's) */
String options[] = {