1 11 package org.eclipse.jdi.internal.event; 12 13 14 import java.io.DataInputStream ; 15 import java.io.IOException ; 16 import java.util.HashMap ; 17 import java.util.Map ; 18 19 import org.eclipse.jdi.internal.MirrorImpl; 20 import org.eclipse.jdi.internal.ThreadReferenceImpl; 21 import org.eclipse.jdi.internal.VirtualMachineImpl; 22 import org.eclipse.jdi.internal.request.RequestID; 23 24 import com.sun.jdi.ThreadReference; 25 import com.sun.jdi.event.Event; 26 import com.sun.jdi.request.EventRequest; 27 28 29 35 public abstract class EventImpl extends MirrorImpl implements Event { 36 37 public static final byte EVENT_SINGLE_STEP = 1; 38 public static final byte EVENT_BREAKPOINT = 2; 39 public static final byte EVENT_FRAME_POP = 3; 40 public static final byte EVENT_EXCEPTION = 4; 41 public static final byte EVENT_USER_DEFINED = 5; 42 public static final byte EVENT_THREAD_START = 6; 43 public static final byte EVENT_THREAD_END = 7; 44 public static final byte EVENT_CLASS_PREPARE = 8; 45 public static final byte EVENT_CLASS_UNLOAD = 9; 46 public static final byte EVENT_CLASS_LOAD = 10; 47 public static final byte EVENT_FIELD_ACCESS = 20; 48 public static final byte EVENT_FIELD_MODIFICATION = 21; 49 public static final byte EVENT_EXCEPTION_CATCH = 30; 50 public static final byte EVENT_METHOD_ENTRY = 40; 51 public static final byte EVENT_METHOD_EXIT = 41; 52 public static final byte EVENT_METHOD_EXIT_WITH_RETURN_VALUE = 42; 53 public static final byte EVENT_MONITOR_CONTENDED_ENTER = 43; 54 public static final byte EVENT_MONITOR_CONTENDED_ENTERED = 44; 55 public static final byte EVENT_MONITOR_WAIT = 45; 56 public static final byte EVENT_MONITOR_WAITED = 46; 57 public static final byte EVENT_VM_INIT = 90; 58 public static final byte EVENT_VM_DEATH = 99; 59 public static final byte EVENT_VM_DISCONNECTED = 100; public static final byte EVENT_VM_START = EVENT_VM_INIT; 61 public static final byte EVENT_THREAD_DEATH = EVENT_THREAD_END; 62 63 64 protected ThreadReferenceImpl fThreadRef; 65 66 67 private static HashMap fEventKindMap = null; 68 69 70 private RequestID fRequestID; 71 72 73 private EventRequest fRequest; 74 75 78 protected EventImpl(String description, VirtualMachineImpl vmImpl, RequestID requestID) { 79 super(description, vmImpl); 80 fRequestID = requestID; 81 } 82 83 86 public ThreadReference thread() { 87 return fThreadRef; 88 } 89 90 93 public RequestID requestID() { 94 return fRequestID; 95 } 96 97 100 public String toString() { 101 return super.toString() + ": " + fRequestID; } 103 104 107 public static EventImpl read(MirrorImpl target, DataInputStream dataInStream) throws IOException { 108 byte eventKind = target.readByte("event kind", eventKindMap(), dataInStream); RequestID requestID = RequestID.read(target, dataInStream); 110 111 EventImpl result; 113 switch(eventKind) { 114 case 0: 115 return null; 116 case AccessWatchpointEventImpl.EVENT_KIND: 117 result = AccessWatchpointEventImpl.read(target, requestID, dataInStream); 118 break; 119 case BreakpointEventImpl.EVENT_KIND: 120 result = BreakpointEventImpl.read(target, requestID, dataInStream); 121 break; 122 case ClassPrepareEventImpl.EVENT_KIND: 123 result = ClassPrepareEventImpl.read(target, requestID, dataInStream); 124 break; 125 case ClassUnloadEventImpl.EVENT_KIND: 126 result = ClassUnloadEventImpl.read(target, requestID, dataInStream); 127 break; 128 case ExceptionEventImpl.EVENT_KIND: 129 result = ExceptionEventImpl.read(target, requestID, dataInStream); 130 break; 131 case MethodEntryEventImpl.EVENT_KIND: 132 result = MethodEntryEventImpl.read(target, requestID, dataInStream); 133 break; 134 case MethodExitEventImpl.EVENT_KIND: 135 result = MethodExitEventImpl.read(target, requestID, dataInStream); 136 break; 137 case EVENT_METHOD_EXIT_WITH_RETURN_VALUE: 138 result = MethodExitEventImpl.readWithReturnValue(target, requestID, dataInStream); 139 break; 140 case MonitorContendedEnteredEventImpl.EVENT_KIND: 141 result = MonitorContendedEnteredEventImpl.read(target, requestID, dataInStream); 142 break; 143 case MonitorContendedEnterEventImpl.EVENT_KIND: 144 result = MonitorContendedEnterEventImpl.read(target, requestID, dataInStream); 145 break; 146 case MonitorWaitedEventImpl.EVENT_KIND: 147 result = MonitorWaitedEventImpl.read(target, requestID, dataInStream); 148 break; 149 case MonitorWaitEventImpl.EVENT_KIND: 150 result = MonitorWaitEventImpl.read(target, requestID, dataInStream); 151 break; 152 case ModificationWatchpointEventImpl.EVENT_KIND: 153 result = ModificationWatchpointEventImpl.read(target, requestID, dataInStream); 154 break; 155 case StepEventImpl.EVENT_KIND: 156 result = StepEventImpl.read(target, requestID, dataInStream); 157 break; 158 case ThreadDeathEventImpl.EVENT_KIND: 159 result = ThreadDeathEventImpl.read(target, requestID, dataInStream); 160 break; 161 case ThreadStartEventImpl.EVENT_KIND: 162 result = ThreadStartEventImpl.read(target, requestID, dataInStream); 163 break; 164 case VMDeathEventImpl.EVENT_KIND: 165 result = VMDeathEventImpl.read(target, requestID, dataInStream); 166 break; 167 case VMDisconnectEventImpl.EVENT_KIND: 168 result = VMDisconnectEventImpl.read(target, requestID, dataInStream); 169 break; 170 case VMStartEventImpl.EVENT_KIND: 171 result = VMStartEventImpl.read(target, requestID, dataInStream); 172 break; 173 default: 174 throw new IOException (EventMessages.EventImpl_Read_invalid_EventKind___1 + eventKind); 175 } 176 177 if (!requestID.isNull()) 179 result.fRequest = target.virtualMachineImpl().eventRequestManagerImpl().findRequest(result); 180 181 return result; 182 } 183 184 187 public EventRequest request() { 188 return fRequest; 189 } 190 191 194 public static void getConstantMaps() { 195 if (fEventKindMap != null) 196 return; 197 198 java.lang.reflect.Field [] fields = EventImpl.class.getDeclaredFields(); 199 fEventKindMap = new HashMap (); 200 for (int i = 0; i < fields.length; i++) { 201 java.lang.reflect.Field field = fields[i]; 202 if ((field.getModifiers() & java.lang.reflect.Modifier.PUBLIC) == 0 || (field.getModifiers() & java.lang.reflect.Modifier.STATIC) == 0 || (field.getModifiers() & java.lang.reflect.Modifier.FINAL) == 0) 203 continue; 204 205 try { 206 String name = field.getName(); 207 Integer intValue = new Integer (field.getInt(null)); 208 209 if (name.startsWith("EVENT_")) { name = name.substring(6); 211 fEventKindMap.put(intValue, name); 212 } 213 } catch (IllegalAccessException e) { 214 } catch (IllegalArgumentException e) { 216 } 220 } 221 } 222 223 226 public static Map eventKindMap() { 227 getConstantMaps(); 228 return fEventKindMap; 229 } 230 } 231 232 | Popular Tags |