3 import java.util.Iterator;
6 import com.sun.jdi.Bootstrap;
7 import com.sun.jdi.VirtualMachine;
8 import com.sun.jdi.connect.Connector;
9 import com.sun.jdi.VMDisconnectedException;
13 * Contains a couple of static functions that simplify managing
14 * virtual machines. Some kind of rearrangement between this class and
15 * the {@link Debugger} class should probably be made - this class
16 * doesn't feel so meaningful at the moment, whereas the methods for
17 * launching/attaching/listening to VMs in the Debugger class are
18 * messy. Something for the future.
21 * Created: Tue Jan 08 18:49:28 2002
23 * @author Petter Måhlén
28 private static List s_connectors = Bootstrap.virtualMachineManager().allConnectors();
36 * @param type connector class name
39 public static final Connector getConnector(String name) {
40 Iterator iter = s_connectors.iterator();
41 while (iter.hasNext()) {
42 Connector connector = (Connector)iter.next();
43 if (connector.name().equals(name)) {
52 * Shut down the indicated virtual machine.
54 * @param vm a <code>VirtualMachine</code> value
56 public static void shutdown(VirtualMachine vm) {
58 * taken from the original (Amit Kumar) DebuggeeProcess.shutdown()
61 * As far as I can understand, vm.dispose() doesn't terminate the process
62 * that is being debugged. It seems to me as if doing so would be necessary
63 * (otherwise the VM process should be orphaned), so this needs to be
67 // isolate the process first
68 Process process = null;
71 process = vm.process();
74 catch (VMDisconnectedException e) {
75 // If it's already disconnected, no problem, so just ignore it.
79 if (process != null) {
81 // XXX sun's jdb implementation works a lot to make sure
82 // the stderr and stdout are dumped before killing
83 // things. i'm not sure how important it is, or even how
84 // well it works (given i can't test it)
85 // sooo, if the reader finds bugs with the output handling
86 // on finish, lemme know. (comment by Amit Kumar)