39 |
|
|
40 |
package gnu.classpath.jdwp.processor; |
package gnu.classpath.jdwp.processor; |
41 |
|
|
|
import gnu.classpath.jdwp.IVirtualMachine; |
|
|
import gnu.classpath.jdwp.Jdwp; |
|
42 |
import gnu.classpath.jdwp.JdwpConstants; |
import gnu.classpath.jdwp.JdwpConstants; |
43 |
|
import gnu.classpath.jdwp.VMVirtualMachine; |
44 |
import gnu.classpath.jdwp.exception.InvalidFieldException; |
import gnu.classpath.jdwp.exception.InvalidFieldException; |
45 |
import gnu.classpath.jdwp.exception.JdwpException; |
import gnu.classpath.jdwp.exception.JdwpException; |
46 |
import gnu.classpath.jdwp.exception.JdwpInternalErrorException; |
import gnu.classpath.jdwp.exception.JdwpInternalErrorException; |
47 |
import gnu.classpath.jdwp.exception.NotImplementedException; |
import gnu.classpath.jdwp.exception.NotImplementedException; |
|
import gnu.classpath.jdwp.id.IdManager; |
|
48 |
import gnu.classpath.jdwp.id.ObjectId; |
import gnu.classpath.jdwp.id.ObjectId; |
49 |
import gnu.classpath.jdwp.id.ReferenceTypeId; |
import gnu.classpath.jdwp.id.ReferenceTypeId; |
50 |
import gnu.classpath.jdwp.util.JdwpString; |
import gnu.classpath.jdwp.util.JdwpString; |
62 |
* |
* |
63 |
* @author Aaron Luchko <aluchko@redhat.com> |
* @author Aaron Luchko <aluchko@redhat.com> |
64 |
*/ |
*/ |
65 |
public class ReferenceTypeCommandSet implements CommandSet |
public class ReferenceTypeCommandSet |
66 |
|
extends CommandSet |
67 |
{ |
{ |
|
// Our hook into the jvm |
|
|
private final IVirtualMachine vm = Jdwp.getIVirtualMachine(); |
|
|
|
|
|
// Manages all the different ids that are assigned by jdwp |
|
|
private final IdManager idMan = Jdwp.getIdManager(); |
|
|
|
|
68 |
public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command) |
public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command) |
69 |
throws JdwpException |
throws JdwpException |
70 |
{ |
{ |
146 |
|
|
147 |
Class clazz = refId.getType(); |
Class clazz = refId.getType(); |
148 |
ClassLoader loader = clazz.getClassLoader(); |
ClassLoader loader = clazz.getClassLoader(); |
149 |
ObjectId oid = idMan.getId(loader); |
ObjectId oid = idMan.getObjectId(loader); |
150 |
oid.write(os); |
oid.write(os); |
151 |
} |
} |
152 |
|
|
170 |
for (int i = 0; i < fields.length; i++) |
for (int i = 0; i < fields.length; i++) |
171 |
{ |
{ |
172 |
Field field = fields[i]; |
Field field = fields[i]; |
173 |
idMan.getId(field).write(os); |
idMan.getObjectId(field).write(os); |
174 |
JdwpString.writeString(os, field.getName()); |
JdwpString.writeString(os, field.getName()); |
175 |
JdwpString.writeString(os, Signature.computeFieldSignature(field)); |
JdwpString.writeString(os, Signature.computeFieldSignature(field)); |
176 |
os.writeInt(field.getModifiers()); |
os.writeInt(field.getModifiers()); |
188 |
for (int i = 0; i < methods.length; i++) |
for (int i = 0; i < methods.length; i++) |
189 |
{ |
{ |
190 |
Method method = methods[i]; |
Method method = methods[i]; |
191 |
idMan.getId(method).write(os); |
idMan.getObjectId(method).write(os); |
192 |
JdwpString.writeString(os, method.getName()); |
JdwpString.writeString(os, method.getName()); |
193 |
JdwpString.writeString(os, Signature.computeMethodSignature(method)); |
JdwpString.writeString(os, Signature.computeMethodSignature(method)); |
194 |
os.writeInt(method.getModifiers()); |
os.writeInt(method.getModifiers()); |
205 |
os.writeInt(numFields); // Looks pointless but this is the protocol |
os.writeInt(numFields); // Looks pointless but this is the protocol |
206 |
for (int i = 0; i < numFields; i++) |
for (int i = 0; i < numFields; i++) |
207 |
{ |
{ |
208 |
ObjectId fieldId = idMan.readId(bb); |
ObjectId fieldId = idMan.readObjectId(bb); |
209 |
Field field = (Field) (fieldId.getObject()); |
Field field = (Field) (fieldId.getObject()); |
210 |
Class fieldClazz = field.getDeclaringClass(); |
Class fieldClazz = field.getDeclaringClass(); |
211 |
|
|
242 |
Class clazz = refId.getType(); |
Class clazz = refId.getType(); |
243 |
|
|
244 |
// We'll need to go into the jvm for this unless there's an easier way |
// We'll need to go into the jvm for this unless there's an easier way |
245 |
String sourceFileName = vm.getSourceFile(clazz); |
String sourceFileName = VMVirtualMachine.getSourceFile(clazz); |
246 |
JdwpString.writeString(os, sourceFileName); |
JdwpString.writeString(os, sourceFileName); |
247 |
// clazz.getProtectionDomain().getCodeSource().getLocation(); |
// clazz.getProtectionDomain().getCodeSource().getLocation(); |
248 |
} |
} |
269 |
Class clazz = refId.getType(); |
Class clazz = refId.getType(); |
270 |
|
|
271 |
// I don't think there's any other way to get this |
// I don't think there's any other way to get this |
272 |
int status = vm.getStatus(clazz); |
int status = VMVirtualMachine.getClassStatus(clazz); |
273 |
os.writeInt(status); |
os.writeInt(status); |
274 |
} |
} |
275 |
|
|
293 |
{ |
{ |
294 |
ReferenceTypeId refId = idMan.readReferenceTypeId(bb); |
ReferenceTypeId refId = idMan.readReferenceTypeId(bb); |
295 |
Class clazz = refId.getType(); |
Class clazz = refId.getType(); |
296 |
ObjectId clazzObjectId = idMan.getId(clazz); |
ObjectId clazzObjectId = idMan.getObjectId(clazz); |
297 |
clazzObjectId.write(os); |
clazzObjectId.write(os); |
298 |
} |
} |
299 |
|
|