1 11 package org.eclipse.jdi.internal.jdwp; 12 13 14 import java.io.IOException ; 15 import java.lang.reflect.Field ; 16 import java.lang.reflect.Modifier ; 17 import java.util.HashMap ; 18 import java.util.Map ; 19 20 25 public class JdwpReplyPacket extends JdwpPacket { 26 27 public static final short NONE = 0; 28 public static final short INVALID_THREAD = 10; 29 public static final short INVALID_THREAD_GROUP = 11; 30 public static final short INVALID_PRIORITY = 12; 31 public static final short THREAD_NOT_SUSPENDED = 13; 32 public static final short THREAD_SUSPENDED = 14; 33 public static final short THREAD_NOT_ALIVE = 15; 34 public static final short INVALID_OBJECT = 20; 35 public static final short INVALID_CLASS = 21; 36 public static final short CLASS_NOT_PREPARED = 22; 37 public static final short INVALID_METHODID = 23; 38 public static final short INVALID_LOCATION = 24; 39 public static final short INVALID_FIELDID = 25; 40 public static final short INVALID_FRAMEID = 30; 41 public static final short NO_MORE_FRAMES = 31; 42 public static final short OPAQUE_FRAME = 32; 43 public static final short NOT_CURRENT_FRAME = 33; 44 public static final short TYPE_MISMATCH = 34; 45 public static final short INVALID_SLOT = 35; 46 public static final short DUPLICATE = 40; 47 public static final short NOT_FOUND = 41; 48 public static final short INVALID_MONITOR = 50; 49 public static final short NOT_MONITOR_OWNER = 51; 50 public static final short INTERRUPT = 52; 51 public static final short INVALID_CLASS_FORMAT = 60; 52 public static final short CIRCULAR_CLASS_DEFINITION = 61; 53 public static final short FAILS_VERIFICATION = 62; 54 public static final short ADD_METHOD_NOT_IMPLEMENTED = 63; 55 public static final short SCHEMA_CHANGE_NOT_IMPLEMENTED = 64; 56 public static final short INVALID_TYPESTATE = 65; 57 public static final short HIERARCHY_CHANGE_NOT_IMPLEMENTED = 66; 58 public static final short DELETE_METHOD_NOT_IMPLEMENTED = 67; 59 public static final short UNSUPPORTED_VERSION = 68; 60 public static final short NAMES_DONT_MATCH = 69; 61 public static final short CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 70; 62 public static final short METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED = 71; 63 public static final short NOT_IMPLEMENTED = 99; 64 public static final short NULL_POINTER = 100; 65 public static final short ABSENT_INFORMATION = 101; 66 public static final short INVALID_EVENT_TYPE = 102; 67 public static final short ILLEGAL_ARGUMENT = 103; 68 public static final short OUT_OF_MEMORY = 110; 69 public static final short ACCESS_DENIED = 111; 70 public static final short VM_DEAD = 112; 71 public static final short INTERNAL = 113; 72 public static final short UNATTACHED_THREAD = 115; 73 public static final short INVALID_TAG = 500; 74 public static final short ALREADY_INVOKING = 502; 75 public static final short INVALID_INDEX = 503; 76 public static final short INVALID_LENGTH = 504; 77 public static final short INVALID_STRING = 506; 78 public static final short INVALID_CLASS_LOADER = 507; 79 public static final short INVALID_ARRAY = 508; 80 public static final short TRANSPORT_LOAD = 509; 81 public static final short TRANSPORT_INIT = 510; 82 public static final short NATIVE_METHOD = 511; 83 public static final short INVALID_COUNT = 512; 84 public static final short HCR_OPERATION_REFUSED = 900; 86 87 private static HashMap fErrorMap = null; 88 89 90 private short fErrorCode; 91 94 public JdwpReplyPacket() { 95 setFlags(FLAG_REPLY_PACKET); 96 } 97 98 101 public short errorCode() { 102 return fErrorCode; 103 } 104 105 108 public void setErrorCode(short newValue) { 109 fErrorCode = newValue; 110 } 111 112 115 protected int readSpecificHeaderFields(byte[] bytes, int index) throws IOException { 116 fErrorCode = (short)((bytes[index] << 8) + (bytes[index+1] << 0)); 117 return 2; 118 } 119 120 123 protected int writeSpecificHeaderFields(byte[] bytes, int index) throws IOException { 124 bytes[index] = (byte) ((fErrorCode >>> 8) & 0xFF); 125 bytes[index+1] = (byte) ((fErrorCode >>> 0) & 0xFF); 126 return 2; 127 } 128 129 132 public static void getConstantMaps() { 133 if (fErrorMap != null) { 134 return; 135 } 136 137 Field [] fields = JdwpReplyPacket.class.getDeclaredFields(); 138 fErrorMap = new HashMap (fields.length); 139 for (int i = 0; i < fields.length; i++) { 140 Field field = fields[i]; 141 if ((field.getModifiers() & Modifier.PUBLIC) == 0 || (field.getModifiers() & Modifier.STATIC) == 0 || (field.getModifiers() & Modifier.FINAL) == 0) 142 continue; 143 144 try { 145 Integer intValue = new Integer (field.getInt(null)); 146 fErrorMap.put(intValue, field.getName()); 147 } catch (IllegalAccessException e) { 148 } catch (IllegalArgumentException e) { 150 } 154 } 155 } 156 157 160 public static Map errorMap() { 161 getConstantMaps(); 162 return fErrorMap; 163 } 164 165 168 public String toString() { 169 StringBuffer buffer = new StringBuffer (); 170 buffer.append("["); buffer.append(getId()); 172 buffer.append("] "); buffer.append("(reply)"); short ec = errorCode(); 175 if (ec != NONE) { 176 buffer.append(" ERROR CODE: "); buffer.append(ec); 178 } 179 return buffer.toString(); 180 } 181 } 182 | Popular Tags |