Initial Commit
[packages] / xemacs-packages / jde / java / src / jde / debugger / command / Interrupt.java
1 package jde.debugger.command;
2
3 import java.util.Iterator;
4
5 import com.sun.jdi.ObjectReference;
6 import com.sun.jdi.ThreadGroupReference;
7 import com.sun.jdi.ThreadReference;
8 import jde.debugger.Etc;
9 import jde.debugger.JDEException;
10
11
12 /**
13  * 'interrupt' command.
14  * <p>
15  *
16  * <b>Syntax:</b>
17  * <pre>
18  * interrupt [threadID]+
19  * </pre>
20  *
21  * <b>Comments:</b>
22  * <ul>
23  * <li> threadID can be retrieved using the get_threads command
24  * <li> at least one threadId should be specified
25  * </ul>
26  *
27  * @author Paul Kinnucan
28  * @version $Revision: 1.2 $
29  * @copyright Copyright (c) 2000, 2001, 2003    Paul Kinnucan
30  *
31  */
32 public class Interrupt extends DebugProcessCommand {
33   
34   /**
35    *
36    * @exception jde.debugger.JDEException <description>
37    */
38   public void doCommand() throws JDEException {
39     if (m_args.size() < 1) 
40       throw new JDEException("Insufficient arguments");
41         
42     Iterator it = m_args.iterator();
43     while (it.hasNext()) {
44       Long uniqueID = Etc.safeGetLong(it.next(), "thread ID");
45             
46       ObjectReference oRef = (ObjectReference) m_debugger.getStore().get(uniqueID);
47       if (oRef == null) {
48         throw new JDEException("Invalid ThreadID, or the thread is dead");
49       } else if (oRef instanceof ThreadReference) {
50         ((ThreadReference) oRef).interrupt();
51       } else {
52         throw new JDEException("The object is not a thread");
53       }
54     }
55     m_debugger.signalCommandResult(m_cmdID, null, CMD_OK);
56   }
57
58   public Object clone() {return new Interrupt();}
59   
60 } // Interrupt
61
62 /*
63  * $Log: Interrupt.java,v $
64  * Revision 1.2  2003/01/15 05:56:26  paulk
65  * Add Petter Mahlen's changes.
66  *
67  * Revision 1.1  2001/03/24 13:35:25  paulk
68  * Initial revision.
69  *
70  *
71  */
72
73 // End of Interrupt.java