Initial Commit
[packages] / xemacs-packages / jde / java / src / jde / debugger / command / KillThread.java
1 package jde.debugger.command;
2
3 import java.util.Iterator;
4
5 import com.sun.jdi.InvalidTypeException;
6 import com.sun.jdi.ObjectReference;
7 import com.sun.jdi.ThreadGroupReference;
8 import com.sun.jdi.ThreadReference;
9 import jde.debugger.Etc;
10 import jde.debugger.JDEException;
11
12
13 /**
14  * 'kill thread' command. Kill a thread with a given exception object.
15  * <p>
16  *
17  * <b>Syntax:</b>
18  * <pre>
19  * kill_thread threadID exceptionObjectID
20  * </pre>
21  *
22  * <b>Comments:</b>
23  * <ul>
24  * <li> threadID can be retrieved using the get_threads command
25  * <li> exceptionObjectID is the object id of a Throwable object. It
26  * can be created using the 'evaluate' command, or an existing throwable
27  * object can be used.
28  * </ul>
29  * 
30  * @author Paul Kinnucan
31  * @version $Revision: 1.2 $
32  * @copyright Copyright (c) 2000, 2001, 2003    Paul Kinnucan
33  *
34  */
35 public class KillThread extends DebugProcessCommand {
36   
37   /**
38    *
39    * @exception jde.debugger.JDEException <description>
40    */
41   public void doCommand() throws JDEException {
42     if (m_args.size() < 2) 
43       throw new JDEException("Insufficient arguments");
44         
45     Long uniqueID = Etc.safeGetLong(m_args.remove(0), "thread ID");
46         
47     ObjectReference oRef = m_debugger.getStore().get(uniqueID);
48     if (oRef == null) {
49       throw new JDEException("No such thread exists");
50     } else if (!(oRef instanceof ThreadReference)) {
51       throw new JDEException("The ID doesn't correspond to a thread");
52     }
53     ThreadReference tRef = (ThreadReference) oRef;
54         
55     uniqueID = Etc.safeGetLong(m_args.remove(0), "thread ID");
56         
57     oRef = m_debugger.getStore().get(uniqueID);
58     if (oRef == null) {
59       throw new JDEException("No such thread exists");
60     }
61         
62     try {
63       tRef.stop(oRef);
64     } catch (InvalidTypeException ex) {
65       throw new JDEException("Object ID doesn't correspond to a Throwable object");
66     }
67     m_debugger.signalCommandResult(m_cmdID, null, CMD_OK);
68   }
69     
70   public Object clone() {return new KillThread();}
71     
72 } // KillThread
73
74 /*
75  * $Log: KillThread.java,v $
76  * Revision 1.2  2003/01/15 05:56:26  paulk
77  * Add Petter Mahlen's changes.
78  *
79  * Revision 1.1  2001/03/24 13:35:25  paulk
80  * Initial revision.
81  *
82  *
83  */
84
85 // End of KillThread.java