aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java')
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java107
1 files changed, 57 insertions, 50 deletions
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
index a7edb287a56..e2703908ba2 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
@@ -1,6 +1,6 @@
/* VirtualMachineCommandSet.java -- class to implement the VirtualMachine
Command Set
- Copyright (C) 2005, 2006 Free Software Foundation
+ Copyright (C) 2005, 2006, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -54,6 +54,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.Properties;
@@ -179,7 +180,8 @@ public class VirtualMachineCommandSet
ArrayList allMatchingClasses = new ArrayList();
// This will be an Iterator over all loaded Classes
- Iterator iter = VMVirtualMachine.getAllLoadedClasses();
+ Collection classes = VMVirtualMachine.getAllLoadedClasses();
+ Iterator iter = classes.iterator ();
while (iter.hasNext())
{
@@ -203,22 +205,11 @@ public class VirtualMachineCommandSet
private void executeAllClasses(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- // Disable garbage collection while we're collecting the info on loaded
- // classes so we some classes don't get collected between the time we get
- // the count and the time we get the list
- //VMVirtualMachine.disableGarbageCollection();
+ Collection classes = VMVirtualMachine.getAllLoadedClasses();
+ os.writeInt(classes.size ());
- int classCount = VMVirtualMachine.getAllLoadedClassesCount();
- os.writeInt(classCount);
-
- // This will be an Iterator over all loaded Classes
- Iterator iter = VMVirtualMachine.getAllLoadedClasses();
- //VMVirtualMachine.enableGarbageCollection();
- int count = 0;
-
- // Note it's possible classes were created since out classCount so make
- // sure we don't write more classes than we told the debugger
- while (iter.hasNext() && count++ < classCount)
+ Iterator iter = classes.iterator ();
+ while (iter.hasNext())
{
Class clazz = (Class) iter.next();
ReferenceTypeId id = idMan.getReferenceTypeId(clazz);
@@ -340,14 +331,13 @@ public class VirtualMachineCommandSet
private void executeCapabilities(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- // Store these somewhere?
- os.writeBoolean(false); // canWatchFieldModification
- os.writeBoolean(false); // canWatchFieldAccess
- os.writeBoolean(false); // canGetBytecodes
- os.writeBoolean(false); // canGetSyntheticAttribute
- os.writeBoolean(false); // canGetOwnedMonitorInfo
- os.writeBoolean(false); // canGetCurrentContendedMonitor
- os.writeBoolean(false); // canGetMonitorInfo
+ os.writeBoolean(VMVirtualMachine.canWatchFieldModification);
+ os.writeBoolean(VMVirtualMachine.canWatchFieldAccess);
+ os.writeBoolean(VMVirtualMachine.canGetBytecodes);
+ os.writeBoolean(VMVirtualMachine.canGetSyntheticAttribute);
+ os.writeBoolean(VMVirtualMachine.canGetOwnedMonitorInfo);
+ os.writeBoolean(VMVirtualMachine.canGetCurrentContendedMonitor);
+ os.writeBoolean(VMVirtualMachine.canGetMonitorInfo);
}
private void executeClassPaths(ByteBuffer bb, DataOutputStream os)
@@ -401,43 +391,60 @@ public class VirtualMachineCommandSet
private void executeCapabilitiesNew(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- // Store these somewhere?
final int CAPABILITIES_NEW_SIZE = 32;
- os.writeBoolean(false); // canWatchFieldModification
- os.writeBoolean(false); // canWatchFieldAccess
- os.writeBoolean(false); // canGetBytecodes
- os.writeBoolean(false); // canGetSyntheticAttribute
- os.writeBoolean(false); // canGetOwnedMonitorInfo
- os.writeBoolean(false); // canGetCurrentContendedMonitor
- os.writeBoolean(false); // canGetMonitorInfo
- os.writeBoolean(false); // canRedefineClasses
- os.writeBoolean(false); // canAddMethod
- os.writeBoolean(false); // canUnrestrictedlyRedefineClasses
- os.writeBoolean(false); // canPopFrames
- os.writeBoolean(false); // canUseInstanceFilters
- os.writeBoolean(false); // canGetSourceDebugExtension
- os.writeBoolean(false); // canRequestVMDeathEvent
- os.writeBoolean(false); // canSetDefaultStratum
+
+ executeCapabilities(bb, os);
+ os.writeBoolean(VMVirtualMachine.canRedefineClasses);
+ os.writeBoolean(VMVirtualMachine.canAddMethod);
+ os.writeBoolean(VMVirtualMachine.canUnrestrictedlyRedefineClasses);
+ os.writeBoolean(VMVirtualMachine.canPopFrames);
+ os.writeBoolean(VMVirtualMachine.canUseInstanceFilters);
+ os.writeBoolean(VMVirtualMachine.canGetSourceDebugExtension);
+ os.writeBoolean(VMVirtualMachine.canRequestVMDeathEvent);
+ os.writeBoolean(VMVirtualMachine.canSetDefaultStratum);
for (int i = 15; i < CAPABILITIES_NEW_SIZE; i++)
- // Future capabilities
- // currently unused
- os.writeBoolean(false); // Set to false
+ {
+ // Future capabilities (currently unused)
+ os.writeBoolean(false);
+ }
}
private void executeRedefineClasses(ByteBuffer bb, DataOutputStream os)
throws JdwpException
{
- // Optional command, don't implement
- throw new NotImplementedException(
- "Command VirtualMachine.RedefineClasses not implemented");
+ if (!VMVirtualMachine.canRedefineClasses)
+ {
+ String msg = "redefinition of classes is not supported";
+ throw new NotImplementedException(msg);
+ }
+
+ int classes = bb.getInt();
+ Class[] types = new Class[classes];
+ byte[][] bytecodes = new byte[classes][];
+ for (int i = 0; i < classes; ++i)
+ {
+ ReferenceTypeId id = idMan.readReferenceTypeId(bb);
+ int classfile = bb.getInt();
+ byte[] bytecode = new byte[classfile];
+ bb.get(bytecode);
+ types[i] = id.getType();
+ bytecodes[i] = bytecode;
+ }
+
+ VMVirtualMachine.redefineClasses (types, bytecodes);
}
private void executeSetDefaultStratum(ByteBuffer bb, DataOutputStream os)
throws JdwpException
{
- // Optional command, don't implement
- throw new NotImplementedException(
- "Command VirtualMachine.SetDefaultStratum not implemented");
+ if (!VMVirtualMachine.canSetDefaultStratum)
+ {
+ String msg = "setting the default stratum is not supported";
+ throw new NotImplementedException(msg);
+ }
+
+ String stratum = JdwpString.readString(bb);
+ VMVirtualMachine.setDefaultStratum(stratum);
}
private void executeAllClassesWithGeneric(ByteBuffer bb, DataOutputStream os)