1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50:
51: import ;
52: import ;
53: import ;
54:
55:
60: public class MethodCommandSet
61: extends CommandSet
62: {
63: public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
64: throws JdwpException
65: {
66: try
67: {
68: switch (command)
69: {
70: case JdwpConstants.CommandSet.Method.LINE_TABLE:
71: executeLineTable(bb, os);
72: break;
73: case JdwpConstants.CommandSet.Method.VARIABLE_TABLE:
74: executeVariableTable(bb, os);
75: break;
76: case JdwpConstants.CommandSet.Method.BYTE_CODES:
77: executeByteCodes(bb, os);
78: break;
79: case JdwpConstants.CommandSet.Method.IS_OBSOLETE:
80: executeIsObsolete(bb, os);
81: break;
82: case JdwpConstants.CommandSet.Method.VARIABLE_TABLE_WITH_GENERIC:
83: executeVariableTableWithGeneric(bb, os);
84: break;
85: default:
86: throw new NotImplementedException(
87: "Command " + command + " not found in Method Command Set.");
88: }
89: }
90: catch (IOException ex)
91: {
92:
93:
94: throw new JdwpInternalErrorException(ex);
95: }
96:
97: return false;
98: }
99:
100: private void executeLineTable(ByteBuffer bb, DataOutputStream os)
101: throws JdwpException, IOException
102: {
103: ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
104: Class clazz = refId.getType();
105:
106: VMMethod method = VMMethod.readId(clazz, bb);
107: LineTable lt = method.getLineTable();
108: lt.write(os);
109: }
110:
111: private void executeVariableTable(ByteBuffer bb, DataOutputStream os)
112: throws JdwpException, IOException
113: {
114: ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
115: Class clazz = refId.getType();
116:
117: VMMethod method = VMMethod.readId(clazz, bb);
118: VariableTable vt = method.getVariableTable();
119: vt.write(os);
120: }
121:
122: private void executeByteCodes(ByteBuffer bb, DataOutputStream os)
123: throws JdwpException, IOException
124: {
125: if (!VMVirtualMachine.canGetBytecodes)
126: {
127: String msg = "getting bytecodes is unsupported";
128: throw new NotImplementedException(msg);
129: }
130:
131: ReferenceTypeId id = idMan.readReferenceTypeId(bb);
132: Class klass = id.getType();
133: VMMethod method = VMMethod.readId(klass, bb);
134: byte[] bytecode = VMVirtualMachine.getBytecodes(method);
135: os.writeInt(bytecode.length);
136: os.write(bytecode);
137: }
138:
139: private void executeIsObsolete(ByteBuffer bb, DataOutputStream os)
140: throws IOException
141: {
142:
143:
144:
145: os.writeBoolean(false);
146: }
147:
148: private void executeVariableTableWithGeneric(ByteBuffer bb,
149: DataOutputStream os)
150: throws JdwpException
151: {
152:
153: throw new NotImplementedException(
154: "Command VariableTableWithGeneric not implemented.");
155: }
156:
157: }