1 /* 2 * Copyright 2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 * CA 95054 USA or visit www.sun.com if you need additional information or 21 * have any questions. 22 * 23 */ 24 25 package sun.jvm.hotspot.debugger.remote; 26 27 import sun.jvm.hotspot.debugger.*; 28 29 public abstract class RemoteThread implements ThreadProxy { 30 protected RemoteDebuggerClient debugger; 31 protected Address addr; 32 protected long id; 33 34 public RemoteThread(RemoteDebuggerClient debugger, Address addr) { 35 this.debugger = debugger; 36 this.addr = addr; 37 this.id = -1L; // invalid, but don't depend on it. check null for addr 38 } 39 40 public RemoteThread(RemoteDebuggerClient debugger, long id) { 41 this.debugger = debugger; 42 this.addr = null; 43 this.id = id; 44 } 45 46 public boolean canSetContext() throws DebuggerException { 47 return false; 48 } 49 50 public void setContext(ThreadContext context) 51 throws IllegalThreadStateException, DebuggerException { 52 throw new DebuggerException("Unimplemented"); 53 } 54 55 public boolean equals(Object o) { 56 if (o == null) { 57 return false; 58 } 59 60 if (! (o instanceof RemoteThread)) { 61 return false; 62 } 63 RemoteThread other = (RemoteThread)o; 64 boolean isOtherAddress = (other.addr != null); 65 boolean isAddress = (addr != null); 66 67 if (isAddress) { 68 return (isOtherAddress)? debugger.areThreadsEqual(addr, other.addr) : 69 debugger.areThreadsEqual(addr, other.id); 70 } else { 71 return (isOtherAddress)? debugger.areThreadsEqual(id, other.addr) : 72 debugger.areThreadsEqual(id, other.id); 73 } 74 } 75 76 public int hashCode() { 77 return (addr != null)? debugger.getThreadHashCode(addr) : 78 debugger.getThreadHashCode(id); 79 } 80 81 public String toString() { 82 return "t@ " + hashCode(); 83 } 84 }