1 /*
2 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
126 public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
127 IOException,
128 IllegalConnectorArgumentsException,
129 VMStartException {
130
131 /*
132 * Get the class name that we are to execute
133 */
134 String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
135 if (className.length() == 0) {
136 throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
137 }
138
139 /*
140 * Listen on an emperical port; launch the debuggee; wait for
141 * for the debuggee to connect; stop listening;
142 */
143 TransportService.ListenKey key = ts.startListening();
144
145 String exe = System.getProperty("java.home") + File.separator + "bin" +
146 File.separator;
147 String arch = System.getProperty("os.arch");
148 String osname = System.getProperty("os.name");
149 if (osname.equals("SunOS") && arch.equals("sparcv9")) {
150 exe += "sparcv9/java";
151 } else if (osname.equals("SunOS") && arch.equals("amd64")) {
152 exe += "amd64/java";
153 } else {
154 exe += "java";
155 }
156 String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
157 key.address() +
158 " -classpath " + System.getProperty("test.classes") +
159 " " + className;
160 Process process = Runtime.getRuntime().exec(cmd);
161 Connection conn = ts.accept(key, 30*1000, 9*1000);
162 ts.stopListening(key);
163
164 /*
165 * Debugee is connected - return the virtual machine mirror
166 */
167 return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
168 }
169 }
|
1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
126 public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
127 IOException,
128 IllegalConnectorArgumentsException,
129 VMStartException {
130
131 /*
132 * Get the class name that we are to execute
133 */
134 String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
135 if (className.length() == 0) {
136 throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
137 }
138
139 /*
140 * Listen on an emperical port; launch the debuggee; wait for
141 * for the debuggee to connect; stop listening;
142 */
143 TransportService.ListenKey key = ts.startListening();
144
145 String exe = System.getProperty("java.home") + File.separator + "bin" +
146 File.separator + "java";
147 String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
148 key.address() +
149 " -classpath " + System.getProperty("test.classes") +
150 " " + className;
151 Process process = Runtime.getRuntime().exec(cmd);
152 Connection conn = ts.accept(key, 30*1000, 9*1000);
153 ts.stopListening(key);
154
155 /*
156 * Debugee is connected - return the virtual machine mirror
157 */
158 return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
159 }
160 }
|