test/com/sun/jdi/NoLaunchOptionTest.java
Print this page
*** 29,38 ****
--- 29,41 ----
*
* @run compile -g NoLaunchOptionTest.java
* @build VMConnection
* @run main/othervm NoLaunchOptionTest
*/
+
+ import java.net.ServerSocket;
+
public class NoLaunchOptionTest extends Object {
private Process subprocess;
private int subprocessStatus;
private static final String CR = System.getProperty("line.separator");
private static final int BUFFERSIZE = 4096;
*** 119,134 ****
return result;
}
public static void main(String[] args) throws Exception {
String javaExe = System.getProperty("java.home") +
java.io.File.separator + "bin" +
java.io.File.separator + "java";
String targetClass = "NotAClass";
String cmds [] = {javaExe,
! "-agentlib:jdwp=transport=dt_socket,address=8000," +
"onthrow=java.lang.ClassNotFoundException,suspend=n",
targetClass};
NoLaunchOptionTest myTest = new NoLaunchOptionTest();
String results [] = myTest.run(VMConnection.insertDebuggeeVMOptions(cmds));
if ((results[RETSTAT].equals("1")) &&
--- 122,144 ----
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 = "NotAClass";
String cmds [] = {javaExe,
! "-agentlib:jdwp=transport=dt_socket,address=" +
! address + "," +
"onthrow=java.lang.ClassNotFoundException,suspend=n",
targetClass};
NoLaunchOptionTest myTest = new NoLaunchOptionTest();
String results [] = myTest.run(VMConnection.insertDebuggeeVMOptions(cmds));
if ((results[RETSTAT].equals("1")) &&