aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2007-03-27 18:40:48 +0000
committerKeith Seitz <kseitz@gcc.gnu.org>2007-03-27 18:40:48 +0000
commitab065b4d759004950fca79cd18a9e186f74f8e0a (patch)
tree8f48f228a7624201f8cd8224b6b277e0d9d3305f /libjava/classpath/gnu
parentdeb2378c1557f269b11464a9d73e0d384c4e4d79 (diff)
downloadgcc-ab065b4d759004950fca79cd18a9e186f74f8e0a.zip
gcc-ab065b4d759004950fca79cd18a9e186f74f8e0a.tar.gz
gcc-ab065b4d759004950fca79cd18a9e186f74f8e0a.tar.bz2
Classpath JDWP merge with upstream
From-SVN: r123265
Diffstat (limited to 'libjava/classpath/gnu')
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/EventManager.java8
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java12
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/exception/InvalidSlotException.java62
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/exception/InvalidTagException.java57
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/exception/TypeMismatchException.java62
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/id/NullObjectId.java79
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java13
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java14
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java25
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/MethodCommandSet.java30
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java34
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java28
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/StackFrameCommandSet.java43
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java42
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java107
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java13
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/util/MonitorInfo.java76
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/util/NullObject.java50
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/util/Value.java301
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/BooleanValue.java100
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/ByteValue.java99
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/CharValue.java100
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/DoubleValue.java100
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/FloatValue.java100
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/IntValue.java100
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/LongValue.java100
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/ObjectValue.java92
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/ShortValue.java100
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/StringValue.java100
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/Value.java155
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/ValueFactory.java247
-rw-r--r--libjava/classpath/gnu/classpath/jdwp/value/VoidValue.java82
32 files changed, 2102 insertions, 429 deletions
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java b/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java
index 54a7b08..02ffa24 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/EventManager.java
@@ -1,5 +1,5 @@
/* EventManager.java -- event management and notification infrastructure
- Copyright (C) 2005, 2006 Free Software Foundation
+ Copyright (C) 2005, 2006, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.classpath.jdwp.event;
+import gnu.classpath.jdwp.Jdwp;
import gnu.classpath.jdwp.VMVirtualMachine;
import gnu.classpath.jdwp.exception.InvalidEventTypeException;
import gnu.classpath.jdwp.exception.JdwpException;
@@ -130,9 +131,10 @@ public class EventManager
// only two: VM_INIT, VM_DEATH
try
{
+ byte sp = (Jdwp.suspendOnStartup()
+ ? EventRequest.SUSPEND_THREAD : EventRequest.SUSPEND_NONE);
requestEvent (new EventRequest (0,
- EventRequest.EVENT_VM_INIT,
- EventRequest.SUSPEND_NONE));
+ EventRequest.EVENT_VM_INIT, sp));
requestEvent (new EventRequest (0,
EventRequest.EVENT_VM_DEATH,
EventRequest.SUSPEND_NONE));
diff --git a/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java b/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java
index 340546e..d18f697 100644
--- a/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java
+++ b/libjava/classpath/gnu/classpath/jdwp/event/filters/StepFilter.java
@@ -1,5 +1,5 @@
/* StepFilter.java -- a step filter
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.classpath.jdwp.event.filters;
+import gnu.classpath.jdwp.JdwpConstants;
import gnu.classpath.jdwp.event.Event;
import gnu.classpath.jdwp.exception.InvalidThreadException;
import gnu.classpath.jdwp.id.ThreadId;
@@ -48,6 +49,12 @@ import gnu.classpath.jdwp.id.ThreadId;
* satisfy depth and size constraints. This modifier can only be used with
* step event kinds."
*
+ * This "filter" is not really a filter. It is simply a way to communicate
+ * stepping information in a convenient way between the JDWP backend and
+ * the virtual machine.
+ *
+ * Consequently, this "filter" always matches.
+ *
* @author Keith Seitz (keiths@redhat.com)
*/
public class StepFilter
@@ -115,7 +122,6 @@ public class StepFilter
*/
public boolean matches (Event event)
{
- // FIXME
- throw new RuntimeException ("StepFilter.matches not implemented");
+ return true;
}
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/exception/InvalidSlotException.java b/libjava/classpath/gnu/classpath/jdwp/exception/InvalidSlotException.java
new file mode 100644
index 0000000..1827eda
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/exception/InvalidSlotException.java
@@ -0,0 +1,62 @@
+/* InvalidSlotException.java -- an invalid variable slot exception
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid Slot id is used by the debugger
+ * (i.e. when trying to access a variable slot which doesn't exist).
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class InvalidSlotException
+ extends JdwpException
+{
+ public InvalidSlotException(int slot)
+ {
+ super(JdwpConstants.Error.INVALID_SLOT, "invalid slot: " + slot);
+ }
+
+ public InvalidSlotException(String msg)
+ {
+ super(JdwpConstants.Error.INVALID_SLOT, msg);
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/exception/InvalidTagException.java b/libjava/classpath/gnu/classpath/jdwp/exception/InvalidTagException.java
new file mode 100644
index 0000000..738b5e7
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/exception/InvalidTagException.java
@@ -0,0 +1,57 @@
+/* InvalidTagException.java -- an invalid type tag exception
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception thrown when an invalid tag is used by
+ * the debugger
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class InvalidTagException
+ extends JdwpException
+{
+ public InvalidTagException (byte tag)
+ {
+ super (JdwpConstants.Error.INVALID_TAG,
+ "invalid tag (" + tag + ")");
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/exception/TypeMismatchException.java b/libjava/classpath/gnu/classpath/jdwp/exception/TypeMismatchException.java
new file mode 100644
index 0000000..c6af652
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/exception/TypeMismatchException.java
@@ -0,0 +1,62 @@
+/* TypeMismatchException.java -- mismatched type of local variable
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.exception;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+/**
+ * An exception throw when attempting to access a local variable of the wrong
+ * type.
+ *
+ * @author Kyle Galloway (kgallowa@redhat.com)
+ */
+public class TypeMismatchException
+ extends JdwpException
+{
+ public TypeMismatchException(byte tag)
+ {
+ super(JdwpConstants.Error.TYPE_MISMATCH, "incorrect tag: " + tag);
+ }
+
+ public TypeMismatchException(String msg)
+ {
+ super(JdwpConstants.Error.TYPE_MISMATCH, msg);
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/id/NullObjectId.java b/libjava/classpath/gnu/classpath/jdwp/id/NullObjectId.java
new file mode 100644
index 0000000..0e7b5e3
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/id/NullObjectId.java
@@ -0,0 +1,79 @@
+/* NullObjectId.java -- special objectId for null values
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.id;
+
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.util.NullObject;
+
+import java.lang.ref.SoftReference;
+
+/**
+ * This is a special case of an ObjectId. When a varaible slot contains
+ * null as its value, this is a valid value despite the fact that it does
+ * not reference an object. To represent this, this will always be the id
+ * of the NullObject (0).
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public class NullObjectId
+ extends ObjectId
+{
+ /**
+ * The object class that this id represents
+ */
+ public static final Class typeClass = NullObject.class;
+
+ /**
+ * Constructs a new <code>NullObjectId</code>
+ */
+ public NullObjectId()
+ {
+ super();
+ setId((long) 0);
+ _reference = new SoftReference<NullObject>(new NullObject());
+ try
+ {
+ disableCollection();
+ }
+ catch(InvalidObjectException ex)
+ {
+ //This will not happen
+ }
+ }
+
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java
index a9dc6cc..0da0154 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/ArrayReferenceCommandSet.java
@@ -1,6 +1,6 @@
/* ArrayReferenceCommandSet.java -- class to implement the Array
Reference Command Set
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -46,7 +46,8 @@ import gnu.classpath.jdwp.exception.JdwpException;
import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
import gnu.classpath.jdwp.exception.NotImplementedException;
import gnu.classpath.jdwp.id.ObjectId;
-import gnu.classpath.jdwp.util.Value;
+import gnu.classpath.jdwp.value.Value;
+import gnu.classpath.jdwp.value.ValueFactory;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -150,11 +151,11 @@ public class ArrayReferenceCommandSet
// tagged
for (int i = first; i < first + length; i++)
{
- Object value = Array.get(array, i);
+ Value val = ValueFactory.createFromObject(Array.get(array, i), clazz);
if (clazz.isPrimitive())
- Value.writeUntaggedValue(os, value);
+ val.writeUntagged(os);
else
- Value.writeTaggedValue(os, value);
+ val.writeTagged(os);
}
}
@@ -168,7 +169,7 @@ public class ArrayReferenceCommandSet
Class type = array.getClass().getComponentType();
for (int i = first; i < first + length; i++)
{
- Object value = Value.getUntaggedObj(bb, type);
+ Object value = Value.getUntaggedObject(bb, type);
Array.set(array, i, value);
}
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
index a3a7ca0..b29b571 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/ClassTypeCommandSet.java
@@ -1,6 +1,6 @@
/* ClassTypeCommandSet.java -- class to implement the ClassType
Command Set
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -49,7 +49,8 @@ import gnu.classpath.jdwp.exception.NotImplementedException;
import gnu.classpath.jdwp.id.ObjectId;
import gnu.classpath.jdwp.id.ReferenceTypeId;
import gnu.classpath.jdwp.util.MethodResult;
-import gnu.classpath.jdwp.util.Value;
+import gnu.classpath.jdwp.value.Value;
+import gnu.classpath.jdwp.value.ValueFactory;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -128,7 +129,7 @@ public class ClassTypeCommandSet
{
ObjectId fieldId = idMan.readObjectId(bb);
Field field = (Field) (fieldId.getObject());
- Object value = Value.getUntaggedObj(bb, field.getType());
+ Object value = Value.getUntaggedObject(bb, field.getType());
try
{
field.setAccessible(true); // Might be a private field
@@ -154,7 +155,8 @@ public class ClassTypeCommandSet
Exception exception = mr.getThrownException();
ObjectId eId = idMan.getObjectId(exception);
- Value.writeTaggedValue(os, value);
+ Value val = ValueFactory.createFromObject(value, mr.getResultType());
+ val.writeTagged(os);
eId.writeTagged(os);
}
@@ -192,7 +194,7 @@ public class ClassTypeCommandSet
for (int i = 0; i < args; i++)
{
- values[i] = Value.getObj(bb);
+ values[i] = Value.getTaggedObject(bb);
}
int invokeOpts = bb.getInt();
@@ -207,6 +209,8 @@ public class ClassTypeCommandSet
MethodResult mr = VMVirtualMachine.executeMethod(null, thread,
clazz, method,
values, false);
+ mr.setResultType(method.getReturnType());
+
if (suspend)
VMVirtualMachine.resumeAllThreads ();
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
index 59cfb94..d7ebbc3 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/EventRequestCommandSet.java
@@ -1,6 +1,6 @@
/* EventRequestCommandSet.java -- class to implement the EventRequest Command
Set
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -40,6 +40,7 @@ exception statement from your version. */
package gnu.classpath.jdwp.processor;
import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMVirtualMachine;
import gnu.classpath.jdwp.event.EventManager;
import gnu.classpath.jdwp.event.EventRequest;
import gnu.classpath.jdwp.event.filters.ClassExcludeFilter;
@@ -113,6 +114,28 @@ public class EventRequestCommandSet
byte suspendPolicy = bb.get();
int modifiers = bb.getInt();
+ switch (eventKind)
+ {
+ case JdwpConstants.EventKind.FIELD_ACCESS:
+ if (!VMVirtualMachine.canWatchFieldAccess)
+ {
+ String msg = "watching field accesses is not supported";
+ throw new NotImplementedException(msg);
+ }
+ break;
+
+ case JdwpConstants.EventKind.FIELD_MODIFICATION:
+ if (!VMVirtualMachine.canWatchFieldModification)
+ {
+ String msg = "watching field modifications is not supported";
+ throw new NotImplementedException(msg);
+ }
+ break;
+
+ default:
+ // okay
+ }
+
EventRequest eventReq = new EventRequest(eventKind, suspendPolicy);
IEventFilter filter = null;
ReferenceTypeId refId;
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/MethodCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/MethodCommandSet.java
index dcfe7a6..4d1bf70 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/MethodCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/MethodCommandSet.java
@@ -1,5 +1,5 @@
/* MethodCommandSet.java -- class to implement the Method Command Set
- Copyright (C) 2005, 2006 Free Software Foundation
+ Copyright (C) 2005, 2006, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -40,10 +40,11 @@ package gnu.classpath.jdwp.processor;
import gnu.classpath.jdwp.JdwpConstants;
import gnu.classpath.jdwp.VMMethod;
+import gnu.classpath.jdwp.VMVirtualMachine;
import gnu.classpath.jdwp.exception.JdwpException;
import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
import gnu.classpath.jdwp.exception.NotImplementedException;
-import gnu.classpath.jdwp.id.ClassReferenceTypeId;
+import gnu.classpath.jdwp.id.ReferenceTypeId;
import gnu.classpath.jdwp.util.LineTable;
import gnu.classpath.jdwp.util.VariableTable;
@@ -99,8 +100,7 @@ public class MethodCommandSet
private void executeLineTable(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- ClassReferenceTypeId refId
- = (ClassReferenceTypeId) idMan.readReferenceTypeId(bb);
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
Class clazz = refId.getType();
VMMethod method = VMMethod.readId(clazz, bb);
@@ -111,8 +111,7 @@ public class MethodCommandSet
private void executeVariableTable(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- ClassReferenceTypeId refId
- = (ClassReferenceTypeId) idMan.readReferenceTypeId(bb);
+ ReferenceTypeId refId = idMan.readReferenceTypeId(bb);
Class clazz = refId.getType();
VMMethod method = VMMethod.readId(clazz, bb);
@@ -121,11 +120,20 @@ public class MethodCommandSet
}
private void executeByteCodes(ByteBuffer bb, DataOutputStream os)
- throws JdwpException
+ throws JdwpException, IOException
{
- // This command is optional, determined by VirtualMachines CapabilitiesNew
- // so we'll leave it till later to implement
- throw new NotImplementedException("Command ByteCodes not implemented.");
+ if (!VMVirtualMachine.canGetBytecodes)
+ {
+ String msg = "getting bytecodes is unsupported";
+ throw new NotImplementedException(msg);
+ }
+
+ ReferenceTypeId id = idMan.readReferenceTypeId(bb);
+ Class klass = id.getType();
+ VMMethod method = VMMethod.readId(klass, bb);
+ byte[] bytecode = VMVirtualMachine.getBytecodes(method);
+ os.writeInt(bytecode.length);
+ os.write(bytecode);
}
private void executeIsObsolete(ByteBuffer bb, DataOutputStream os)
@@ -143,7 +151,7 @@ public class MethodCommandSet
{
// We don't have generics yet
throw new NotImplementedException(
- "Command SourceDebugExtension not implemented.");
+ "Command VariableTableWithGeneric not implemented.");
}
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
index ef421ea..ed83fd2 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/ObjectReferenceCommandSet.java
@@ -1,6 +1,6 @@
/* ObjectReferenceCommandSet.java -- class to implement the ObjectReference
Command Set
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -47,8 +47,10 @@ import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
import gnu.classpath.jdwp.exception.NotImplementedException;
import gnu.classpath.jdwp.id.ObjectId;
import gnu.classpath.jdwp.id.ReferenceTypeId;
-import gnu.classpath.jdwp.util.Value;
import gnu.classpath.jdwp.util.MethodResult;
+import gnu.classpath.jdwp.util.MonitorInfo;
+import gnu.classpath.jdwp.value.Value;
+import gnu.classpath.jdwp.value.ValueFactory;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -137,7 +139,9 @@ public class ObjectReferenceCommandSet
{
field.setAccessible(true); // Might be a private field
Object value = field.get(obj);
- Value.writeTaggedValue(os, value);
+ Value val = ValueFactory.createFromObject(value,
+ field.getType());
+ val.writeTagged(os);
}
catch (IllegalArgumentException ex)
{
@@ -163,7 +167,7 @@ public class ObjectReferenceCommandSet
for (int i = 0; i < numFields; i++)
{
Field field = (Field) idMan.readObjectId(bb).getObject();
- Object value = Value.getUntaggedObj(bb, field.getType());
+ Object value = Value.getUntaggedObject(bb, field.getType());
try
{
field.setAccessible(true); // Might be a private field
@@ -183,13 +187,18 @@ public class ObjectReferenceCommandSet
}
private void executeMonitorInfo(ByteBuffer bb, DataOutputStream os)
- throws JdwpException
+ throws JdwpException, IOException
{
- // This command is optional, determined by VirtualMachines CapabilitiesNew
- // so we'll leave it till later to implement
- throw new NotImplementedException(
- "Command ExecuteMonitorInfo not implemented.");
+ if (!VMVirtualMachine.canGetMonitorInfo)
+ {
+ String msg = "getting monitor info not supported";
+ throw new NotImplementedException(msg);
+ }
+ ObjectId oid = idMan.readObjectId(bb);
+ Object obj = oid.getObject();
+ MonitorInfo info = VMVirtualMachine.getMonitorInfo(obj);
+ info.write(os);
}
private void executeInvokeMethod(ByteBuffer bb, DataOutputStream os)
@@ -212,7 +221,7 @@ public class ObjectReferenceCommandSet
for (int i = 0; i < args; i++)
{
- values[i] = Value.getObj(bb);
+ values[i] = Value.getTaggedObject(bb);
}
int invokeOptions = bb.getInt();
@@ -232,11 +241,14 @@ public class ObjectReferenceCommandSet
MethodResult mr = VMVirtualMachine.executeMethod(obj, thread,
clazz, method,
values, nonVirtual);
+ mr.setResultType (method.getReturnType());
+
Object value = mr.getReturnedValue();
Exception exception = mr.getThrownException();
ObjectId eId = idMan.getObjectId(exception);
- Value.writeTaggedValue(os, value);
+ Value val = ValueFactory.createFromObject(value, mr.getResultType());
+ val.writeTagged(os);
eId.writeTagged(os);
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java
index b76143f..8e8b74b 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/ReferenceTypeCommandSet.java
@@ -1,6 +1,6 @@
/* ReferenceTypeCommandSet.java -- class to implement the ReferenceType
Command Set
- Copyright (C) 2005, 2006 Free Software Foundation
+ Copyright (C) 2005, 2006, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -51,7 +51,8 @@ import gnu.classpath.jdwp.id.ObjectId;
import gnu.classpath.jdwp.id.ReferenceTypeId;
import gnu.classpath.jdwp.util.JdwpString;
import gnu.classpath.jdwp.util.Signature;
-import gnu.classpath.jdwp.util.Value;
+import gnu.classpath.jdwp.value.Value;
+import gnu.classpath.jdwp.value.ValueFactory;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -220,7 +221,9 @@ public class ReferenceTypeCommandSet
{
field.setAccessible(true); // Might be a private field
Object value = field.get(null);
- Value.writeTaggedValue(os, value);
+ Value val = ValueFactory.createFromObject(value,
+ field.getType());
+ val.writeTagged(os);
}
catch (IllegalArgumentException ex)
{
@@ -303,10 +306,15 @@ public class ReferenceTypeCommandSet
private void executeSourceDebugExtension(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- // This command is optional, determined by VirtualMachines CapabilitiesNew
- // so we'll leave it till later to implement
- throw new NotImplementedException(
- "Command SourceDebugExtension not implemented.");
+ if (!VMVirtualMachine.canGetSourceDebugExtension)
+ {
+ String msg = "source debug extension is not supported";
+ throw new NotImplementedException(msg);
+ }
+
+ ReferenceTypeId id = idMan.readReferenceTypeId(bb);
+ String ext = VMVirtualMachine.getSourceDebugExtension (id.getType());
+ JdwpString.writeString(os, ext);
}
private void executeSignatureWithGeneric(ByteBuffer bb, DataOutputStream os)
@@ -314,7 +322,7 @@ public class ReferenceTypeCommandSet
{
// We don't have generics yet
throw new NotImplementedException(
- "Command SourceDebugExtension not implemented.");
+ "Command SignatureWithGeneric not implemented.");
}
private void executeFieldWithGeneric(ByteBuffer bb, DataOutputStream os)
@@ -322,7 +330,7 @@ public class ReferenceTypeCommandSet
{
// We don't have generics yet
throw new NotImplementedException(
- "Command SourceDebugExtension not implemented.");
+ "Command executeFieldWithGeneric not implemented.");
}
private void executeMethodsWithGeneric(ByteBuffer bb, DataOutputStream os)
@@ -330,6 +338,6 @@ public class ReferenceTypeCommandSet
{
// We don't have generics yet
throw new NotImplementedException(
- "Command SourceDebugExtension not implemented.");
+ "Command executeMethodsWithGeneric not implemented.");
}
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/StackFrameCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/StackFrameCommandSet.java
index cf1e8c2..2d90e80 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/StackFrameCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/StackFrameCommandSet.java
@@ -45,8 +45,10 @@ import gnu.classpath.jdwp.VMVirtualMachine;
import gnu.classpath.jdwp.exception.JdwpException;
import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
import gnu.classpath.jdwp.exception.NotImplementedException;
-import gnu.classpath.jdwp.id.ObjectId;
-import gnu.classpath.jdwp.util.Value;
+import gnu.classpath.jdwp.id.ThreadId;
+import gnu.classpath.jdwp.value.ObjectValue;
+import gnu.classpath.jdwp.value.Value;
+import gnu.classpath.jdwp.value.ValueFactory;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -98,8 +100,8 @@ public class StackFrameCommandSet
private void executeGetValues(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- ObjectId tId = idMan.readObjectId(bb);
- Thread thread = (Thread) tId.getObject();
+ ThreadId tId = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tId.getThread();
// Although Frames look like other ids they are not. First they are not
// ObjectIds since they don't exist in the users code. Storing them as an
@@ -115,16 +117,16 @@ public class StackFrameCommandSet
{
int slot = bb.getInt();
byte sig = bb.get();
- Object val = frame.getValue(slot);
- Value.writeTaggedValue(os, val);
+ Value val = frame.getValue(slot, sig);
+ val.writeTagged(os);
}
}
private void executeSetValues(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- ObjectId tId = idMan.readObjectId(bb);
- Thread thread = (Thread) tId.getObject();
+ ThreadId tId = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tId.getThread();
long frameID = bb.getLong();
VMFrame frame = VMVirtualMachine.getFrame(thread, frameID);
@@ -133,7 +135,7 @@ public class StackFrameCommandSet
for (int i = 0; i < slots; i++)
{
int slot = bb.getInt();
- Object value = Value.getObj(bb);
+ Value value = ValueFactory.createFromTagged(bb);
frame.setValue(slot, value);
}
}
@@ -141,21 +143,28 @@ public class StackFrameCommandSet
private void executeThisObject(ByteBuffer bb, DataOutputStream os)
throws JdwpException, IOException
{
- ObjectId tId = idMan.readObjectId(bb);
- Thread thread = (Thread) tId.getObject();
+ ThreadId tId = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tId.getThread();
long frameID = bb.getLong();
VMFrame frame = VMVirtualMachine.getFrame(thread, frameID);
- Object thisObject = frame.getObject();
- Value.writeTaggedValue(os, thisObject);
+ ObjectValue objVal = new ObjectValue(frame.getObject());
+ objVal.writeTagged(os);
}
private void executePopFrames(ByteBuffer bb, DataOutputStream os)
- throws JdwpException
+ throws JdwpException, IOException
{
- // This command is optional, determined by VirtualMachines CapabilitiesNew
- // so we'll leave it till later to implement
- throw new NotImplementedException("Command PopFrames not implemented.");
+ if (!VMVirtualMachine.canPopFrames)
+ {
+ String msg = "popping frames is unsupported";
+ throw new NotImplementedException(msg);
+ }
+
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ long fid = bb.getLong();
+ VMVirtualMachine.popFrames(thread, fid);
}
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java
index fd7fa74..0dd1020 100644
--- a/libjava/classpath/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java
+++ b/libjava/classpath/gnu/classpath/jdwp/processor/ThreadReferenceCommandSet.java
@@ -1,5 +1,5 @@
/* ThreadReferenceCommandSet.java -- class to implement the ThreadReference
- Command Set Copyright (C) 2005 Free Software Foundation
+ Command Set Copyright (C) 2005, 2007 Free Software Foundation
This file is part of GNU Classpath.
@@ -198,22 +198,42 @@ public class ThreadReferenceCommandSet
}
private void executeOwnedMonitors(ByteBuffer bb, DataOutputStream os)
- throws JdwpException
+ throws JdwpException, IOException
{
- // This command is optional, determined by VirtualMachines CapabilitiesNew
- // so we'll leave it till later to implement
- throw new NotImplementedException(
- "Command OwnedMonitors not implemented.");
+ if (!VMVirtualMachine.canGetOwnedMonitorInfo)
+ {
+ String msg = "getting owned monitors is not supported";
+ throw new NotImplementedException(msg);
+ }
+
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+ Object[] monitors = VMVirtualMachine.getOwnedMonitors(thread);
+
+ os.write(monitors.length);
+ for (int i = 0; i < monitors.length; ++i)
+ {
+ ObjectId id = idMan.getObjectId(monitors[i]);
+ id.writeTagged(os);
+ }
}
private void executeCurrentContendedMonitor(ByteBuffer bb,
DataOutputStream os)
- throws JdwpException
+ throws JdwpException, IOException
{
- // This command is optional, determined by VirtualMachines CapabilitiesNew
- // so we'll leave it till later to implement
- throw new NotImplementedException(
- "Command CurrentContentedMonitors not implemented.");
+ if (!VMVirtualMachine.canGetCurrentContendedMonitor)
+ {
+ String msg = "getting current contended monitor is not supported";
+ throw new NotImplementedException(msg);
+ }
+
+ ThreadId tid = (ThreadId) idMan.readObjectId(bb);
+ Thread thread = tid.getThread();
+
+ Object monitor = VMVirtualMachine.getCurrentContendedMonitor(thread);
+ ObjectId id = idMan.getObjectId(monitor);
+ id.writeTagged(os);
}
private void executeStop(ByteBuffer bb, DataOutputStream os)
diff --git a/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java b/libjava/classpath/gnu/classpath/jdwp/processor/VirtualMachineCommandSet.java
index a7edb28..e270390 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)
diff --git a/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java b/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java
index a9c1b33..190511d 100644
--- a/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java
+++ b/libjava/classpath/gnu/classpath/jdwp/util/MethodResult.java
@@ -52,6 +52,9 @@ public class MethodResult
// Any Exception that was thrown by the executing method
private Exception thrownException;
+
+ // The type of this result
+ private Class resType;
public Object getReturnedValue()
{
@@ -73,4 +76,14 @@ public class MethodResult
this.thrownException = thrownException;
}
+ public Class getResultType()
+ {
+ return resType;
+ }
+
+ public void setResultType(Class type)
+ {
+ resType = type;
+ }
+
}
diff --git a/libjava/classpath/gnu/classpath/jdwp/util/MonitorInfo.java b/libjava/classpath/gnu/classpath/jdwp/util/MonitorInfo.java
new file mode 100644
index 0000000..f28eabf
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/util/MonitorInfo.java
@@ -0,0 +1,76 @@
+/* MonitorInfo.java -- class used to return monitor information
+ for JDWP.
+
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.util;
+
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * This class is used to pass monitor information between
+ * the JDWP back-end and the virtual machine.
+ *
+ * @author Keith Seitz (keiths@redhat.com)
+ */
+public class MonitorInfo
+{
+ public int entryCount;
+ public Thread owner;
+ public Thread[] waiters;
+
+ public void write(DataOutputStream os)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ObjectId id = idm.getObjectId(owner);
+ id.write(os);
+ os.write(entryCount);
+ os.write(waiters.length);
+ for (int i = 0; i < waiters.length; ++i)
+ {
+ id = idm.getObjectId(waiters[i]);
+ id.write(os);
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/util/NullObject.java b/libjava/classpath/gnu/classpath/jdwp/util/NullObject.java
new file mode 100644
index 0000000..ec762fc
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/util/NullObject.java
@@ -0,0 +1,50 @@
+/* NullObject.java -- placeholder for null values
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.util;
+
+/**
+ * This is a placeholder for null. There are several places in JDWP where null
+ * is a valid value (i.e. when geting the value of a variable slot that
+ * contains a null reference at that time). This class distinguishes between
+ * these "meaningful" null values and invalid null pointers.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public class NullObject
+{
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/util/Value.java b/libjava/classpath/gnu/classpath/jdwp/util/Value.java
index 414c4a3..e69de29 100644
--- a/libjava/classpath/gnu/classpath/jdwp/util/Value.java
+++ b/libjava/classpath/gnu/classpath/jdwp/util/Value.java
@@ -1,301 +0,0 @@
-/* Value.java -- class to read/write JDWP tagged and untagged values
- Copyright (C) 2005, 2006, Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.classpath.jdwp.util;
-
-import gnu.classpath.jdwp.JdwpConstants;
-import gnu.classpath.jdwp.VMIdManager;
-import gnu.classpath.jdwp.exception.InvalidFieldException;
-import gnu.classpath.jdwp.exception.JdwpException;
-import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
-import gnu.classpath.jdwp.exception.NotImplementedException;
-import gnu.classpath.jdwp.id.ObjectId;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * A class to read/write JDWP tagged and untagged values.
- *
- * @author Aaron Luchko <aluchko@redhat.com>
- */
-public class Value
-{
- /**
- * Will write the given object as an untagged value to the DataOutputStream.
- *
- * @param os write the value here
- * @param obj the Object to write
- * @throws IOException
- * @throws InvalidFieldException
- */
- public static void writeUntaggedValue(DataOutputStream os, Object obj)
- throws JdwpException, IOException
- {
- writeValue(os, obj, false);
- }
-
- /**
- * Will write the given object as a tagged value to the DataOutputStream.
- *
- * @param os write the value here
- * @param obj the Object to write
- * @throws IOException
- * @throws InvalidFieldException
- */
- public static void writeTaggedValue(DataOutputStream os, Object obj)
- throws JdwpException, IOException
- {
- writeValue(os, obj, true);
- }
-
- /**
- * Will write the given object as either a value or an untagged value to the
- * DataOutputStream.
- *
- * @param os write the value here
- * @param obj the Object to write
- * @param tagged true if the value is tagged, false otherwise
- * @throws IOException
- * @throws InvalidFieldException
- */
- private static void writeValue(DataOutputStream os, Object obj,
- boolean tagged)
- throws IOException, JdwpException
- {
- Class clazz = obj.getClass();
- if (clazz.isPrimitive())
- {
- if (clazz == byte.class)
- {
- if (tagged)
- os.writeByte(JdwpConstants.Tag.BYTE);
- os.writeByte(((Byte) obj).byteValue());
- }
- else if (clazz == char.class)
- {
- if (tagged)
- os.writeByte(JdwpConstants.Tag.CHAR);
- os.writeChar(((Character) obj).charValue());
- }
- else if (clazz == float.class)
- {
- if (tagged)
- os.writeByte(JdwpConstants.Tag.FLOAT);
- os.writeFloat(((Float) obj).floatValue());
- }
- else if (clazz == double.class)
- {
- if (tagged)
- os.writeByte(JdwpConstants.Tag.DOUBLE);
- os.writeDouble(((Double) obj).doubleValue());
- }
- else if (clazz == int.class)
- {
- if (tagged)
- os.writeByte(JdwpConstants.Tag.BYTE);
- os.writeInt(((Integer) obj).intValue());
- }
- else if (clazz == long.class)
- {
- if (tagged)
- os.writeByte(JdwpConstants.Tag.LONG);
- os.writeLong(((Long) obj).longValue());
- }
- else if (clazz == short.class)
- {
- if (tagged)
- os.writeByte(JdwpConstants.Tag.SHORT);
- os.writeInt(((Short) obj).shortValue());
- }
- else if (clazz == void.class)
- { // A 'void' has no data
- if (tagged)
- os.writeByte(JdwpConstants.Tag.VOID);
- }
- else if (clazz == boolean.class)
- {
- if (tagged)
- os.writeByte(JdwpConstants.Tag.BOOLEAN);
- os.writeBoolean(((Boolean) obj).booleanValue());
- }
- else
- { // This shouldn't be possible
- throw new JdwpInternalErrorException(
- "Field has invalid primitive!");
- }
- }
- else
- {
- // Object is an Object, not a primitive type wrapped in an object
- // Write the appropriate tag
- if (tagged)
- {
- if (clazz.isArray())
- os.writeByte(JdwpConstants.Tag.ARRAY);
- else if (obj instanceof String)
- os.writeByte(JdwpConstants.Tag.STRING);
- else if (obj instanceof Thread)
- os.writeByte(JdwpConstants.Tag.THREAD);
- else if (obj instanceof ThreadGroup)
- os.writeByte(JdwpConstants.Tag.THREAD_GROUP);
- else if (obj instanceof ClassLoader)
- os.writeByte(JdwpConstants.Tag.CLASS_LOADER);
- else if (obj instanceof Class)
- os.writeByte(JdwpConstants.Tag.CLASS_OBJECT);
- else
- os.writeByte(JdwpConstants.Tag.OBJECT);
- }
- ObjectId oid = VMIdManager.getDefault().getObjectId(obj);
- oid.write(os);
- }
- }
-
- /**
- * Reads the appropriate object for the tagged value contained in the
- * ByteBuffer.
- *
- * @param bb contains the Object
- * @return The Object referenced by the value
- * @throws JdwpException
- * @throws IOException
- */
- public static Object getObj(ByteBuffer bb)
- throws JdwpException, IOException
- {
- return getUntaggedObj(bb, bb.get());
- }
-
- /**
- * Reads an object of the given Class from the untagged value contained
- * in the ByteBuffer.
- *
- * @param bb contains the Object
- * @param type corresponds to the TAG of value to be read
- * @return the resultant object
- * @throws JdwpException
- * @throws IOException
- */
- public static Object getUntaggedObj(ByteBuffer bb, Class type)
- throws JdwpException, IOException
- {
- if (type.isPrimitive())
- {
- if (type == byte.class)
- return new Byte(bb.get());
- else if (type == char.class)
- return new Character(bb.getChar());
- else if (type == float.class)
- return new Float(bb.getFloat());
- else if (type == double.class)
- return new Double(bb.getDouble());
- else if (type == int.class)
- return new Integer(bb.getInt());
- else if (type == long.class)
- return new Long(bb.getLong());
- else if (type == short.class)
- return new Short(bb.getShort());
- else if (type == boolean.class)
- return Boolean.valueOf(bb.get() != 0);
- else if (type == void.class)
- return new byte[0];
- else
- { // This shouldn't be possible
- throw new JdwpInternalErrorException(
- "Field has invalid primitive!");
- }
- }
- else
- {
- // Field is an object
- ObjectId oid = VMIdManager.getDefault().readObjectId(bb);
- return oid.getObject();
- }
- }
-
- /**
- * Reads the an object of the given Class from the untagged value contained
- * in the ByteBuffer.
- *
- * @param bb contains the Object
- * @param tag TAG of the Value to be read
- * @return the object
- * @throws JdwpException
- * @throws IOException
- */
- public static Object getUntaggedObj(ByteBuffer bb, byte tag)
- throws JdwpException, IOException
- {
- switch (tag)
- {
- case JdwpConstants.Tag.BYTE:
- return new Byte(bb.get());
- case JdwpConstants.Tag.CHAR:
- return new Character(bb.getChar());
- case JdwpConstants.Tag.FLOAT:
- return new Float(bb.getFloat());
- case JdwpConstants.Tag.DOUBLE:
- return new Double(bb.getDouble());
- case JdwpConstants.Tag.INT:
- return new Integer(bb.getInt());
- case JdwpConstants.Tag.LONG:
- return new Long(bb.getLong());
- case JdwpConstants.Tag.SHORT:
- return new Short(bb.getShort());
- case JdwpConstants.Tag.VOID:
- return new byte[0];
- case JdwpConstants.Tag.BOOLEAN:
- return (bb.get() == 0) ? new Boolean(false) : new Boolean(true);
- case JdwpConstants.Tag.STRING:
- return JdwpString.readString(bb);
- case JdwpConstants.Tag.ARRAY:
- case JdwpConstants.Tag.THREAD:
- case JdwpConstants.Tag.OBJECT:
- case JdwpConstants.Tag.THREAD_GROUP:
- case JdwpConstants.Tag.CLASS_LOADER:
- case JdwpConstants.Tag.CLASS_OBJECT:
- // All these cases are ObjectIds
- ObjectId oid = VMIdManager.getDefault().readObjectId(bb);
- return oid.getObject();
- default:
- throw new NotImplementedException("Tag " + tag
- + " is not implemented.");
- }
- }
-}
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/BooleanValue.java b/libjava/classpath/gnu/classpath/jdwp/value/BooleanValue.java
new file mode 100644
index 0000000..42bb806
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/BooleanValue.java
@@ -0,0 +1,100 @@
+/* BooleanValue.java -- JDWP wrapper class for a boolean value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an boolean value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class BooleanValue
+ extends Value
+{
+ // The boolean wrapped by this class
+ boolean _value;
+
+ /**
+ * Create a new BooleanValue from an boolean
+ *
+ * @param value the boolean to wrap
+ */
+ public BooleanValue(boolean value)
+ {
+ super(JdwpConstants.Tag.BOOLEAN);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public boolean getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return new Boolean(_value);
+ }
+
+ /**
+ * Write the wrapped boolean to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeBoolean(_value);
+ }
+}
+
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ByteValue.java b/libjava/classpath/gnu/classpath/jdwp/value/ByteValue.java
new file mode 100644
index 0000000..204fe86
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/ByteValue.java
@@ -0,0 +1,99 @@
+/* ByteValue.java -- JDWP wrapper class for a byte value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an byte value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class ByteValue
+ extends Value
+{
+ // The byte wrapped by this class
+ byte _value;
+
+ /**
+ * Create a new ByteValue from an byte
+ *
+ * @param value the byte to wrap
+ */
+ public ByteValue(byte value)
+ {
+ super(JdwpConstants.Tag.BYTE);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public byte getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return new Byte(_value);
+ }
+
+ /**
+ * Write the wrapped byte to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeByte(_value);
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/CharValue.java b/libjava/classpath/gnu/classpath/jdwp/value/CharValue.java
new file mode 100644
index 0000000..f68fc88
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/CharValue.java
@@ -0,0 +1,100 @@
+/* CharValue.java -- JDWP wrapper class for a char value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an char value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class CharValue
+ extends Value
+{
+ // The char wrapped by this class
+ char _value;
+
+ /**
+ * Create a new CharValue from an char
+ *
+ * @param value the char to wrap
+ */
+ public CharValue(char value)
+ {
+ super(JdwpConstants.Tag.CHAR);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public char getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return new Character(_value);
+ }
+
+ /**
+ * Write the wrapped char to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeChar(_value);
+ }
+}
+
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/DoubleValue.java b/libjava/classpath/gnu/classpath/jdwp/value/DoubleValue.java
new file mode 100644
index 0000000..45923c4
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/DoubleValue.java
@@ -0,0 +1,100 @@
+/* DoubleValue.java -- JDWP wrapper class for a double value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an double value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class DoubleValue
+ extends Value
+{
+ // The double wrapped by this class
+ double _value;
+
+ /**
+ * Create a new DoubleValue from an double
+ *
+ * @param value the double to wrap
+ */
+ public DoubleValue(double value)
+ {
+ super(JdwpConstants.Tag.DOUBLE);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public double getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return new Double(_value);
+ }
+
+ /**
+ * Write the wrapped double to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeDouble(_value);
+ }
+}
+
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/FloatValue.java b/libjava/classpath/gnu/classpath/jdwp/value/FloatValue.java
new file mode 100644
index 0000000..970f77c
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/FloatValue.java
@@ -0,0 +1,100 @@
+/* FloatValue.java -- JDWP wrapper class for a float value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+afloat with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an float value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class FloatValue
+ extends Value
+{
+ // The float wrapped by this class
+ float _value;
+
+ /**
+ * Create a new FloatValue from an float
+ *
+ * @param value the float to wrap
+ */
+ public FloatValue(float value)
+ {
+ super(JdwpConstants.Tag.FLOAT);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public float getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return new Float(_value);
+ }
+
+ /**
+ * Write the wrapped float to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeFloat(_value);
+ }
+}
+
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/IntValue.java b/libjava/classpath/gnu/classpath/jdwp/value/IntValue.java
new file mode 100644
index 0000000..2786875
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/IntValue.java
@@ -0,0 +1,100 @@
+/* IntValue.java -- JDWP wrapper class for an int value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an int value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class IntValue
+ extends Value
+{
+ // The int wrapped by this class
+ int _value;
+
+ /**
+ * Create a new IntValue from an int
+ *
+ * @param value the int to wrap
+ */
+ public IntValue(int value)
+ {
+ super(JdwpConstants.Tag.INT);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public int getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return new Integer(_value);
+ }
+
+ /**
+ * Write the wrapped int to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeInt(_value);
+ }
+}
+
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/LongValue.java b/libjava/classpath/gnu/classpath/jdwp/value/LongValue.java
new file mode 100644
index 0000000..0ebe0e9
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/LongValue.java
@@ -0,0 +1,100 @@
+/* LongValue.java -- JDWP wrapper class for a long value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an long value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class LongValue
+ extends Value
+{
+ // The long wrapped by this class
+ long _value;
+
+ /**
+ * Create a new LongValue from an long
+ *
+ * @param value the long to wrap
+ */
+ public LongValue(long value)
+ {
+ super(JdwpConstants.Tag.LONG);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public long getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return new Long(_value);
+ }
+
+ /**
+ * Write the wrapped long to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeLong(_value);
+ }
+}
+
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ObjectValue.java b/libjava/classpath/gnu/classpath/jdwp/value/ObjectValue.java
new file mode 100644
index 0000000..7ec9beb
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/ObjectValue.java
@@ -0,0 +1,92 @@
+/* ObjectValue.java -- JDWP wrapper class for an Object value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.id.ObjectId;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an Object value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class ObjectValue
+ extends Value
+{
+ // The Object wrapped by this class
+ Object _value;
+
+ /**
+ * Create a new ObjectValue from an Object
+ *
+ * @param value the Object to wrap
+ */
+ public ObjectValue(Object value)
+ {
+ super(JdwpConstants.Tag.OBJECT);
+ _value = value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return _value;
+ }
+
+ /**
+ * Write the wrapped object to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ ObjectId oid = VMIdManager.getDefault().getObjectId(_value);
+ oid.write(os);
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ShortValue.java b/libjava/classpath/gnu/classpath/jdwp/value/ShortValue.java
new file mode 100644
index 0000000..cbde226
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/ShortValue.java
@@ -0,0 +1,100 @@
+/* ShortValue.java -- JDWP wrapper class for a short value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an short value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class ShortValue
+ extends Value
+{
+ // The short wrapped by this class
+ short _value;
+
+ /**
+ * Create a new ShortValue from a short
+ *
+ * @param value the short to wrap
+ */
+ public ShortValue(short value)
+ {
+ super(JdwpConstants.Tag.SHORT);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public short getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return new Short(_value);
+ }
+
+ /**
+ * Write the wrapped short to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ os.writeShort(_value);
+ }
+}
+
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/StringValue.java b/libjava/classpath/gnu/classpath/jdwp/value/StringValue.java
new file mode 100644
index 0000000..2371547
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/StringValue.java
@@ -0,0 +1,100 @@
+/* StringValue.java -- JDWP wrapper class for an String value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.util.JdwpString;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an String value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public final class StringValue
+ extends Value
+{
+ // The String wrapped by this class
+ String _value;
+
+ /**
+ * Create a new StringValue from an String
+ *
+ * @param value the String to wrap
+ */
+ public StringValue(String value)
+ {
+ super(JdwpConstants.Tag.OBJECT);
+ _value = value;
+ }
+
+ /**
+ * Get the value held in this Value
+ *
+ * @return the value represented by this Value object
+ */
+ public String getValue()
+ {
+ return _value;
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return _value;
+ }
+
+ /**
+ * Write the wrapped object to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ JdwpString.writeString(os, _value);
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/Value.java b/libjava/classpath/gnu/classpath/jdwp/value/Value.java
new file mode 100644
index 0000000..4ad8bec
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/Value.java
@@ -0,0 +1,155 @@
+/* Value.java -- base class of JDWP values
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.exception.InvalidTagException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * Superclass for all JDWP Values.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public abstract class Value
+{
+ // A Tag representing the type of this value
+ private byte _tag;
+
+ /**
+ * Create a new value of type tag.
+ *
+ * @param tag the type of the value
+ */
+ protected Value(byte tag)
+ {
+ _tag = tag;
+ }
+
+ /**
+ * Get the tag for this Value
+ *
+ * @return the byte tag of this Value
+ */
+ public byte getTag()
+ {
+ return _tag;
+ }
+
+ /**
+ * Calls the dervied classes writeValue method to write its value to the
+ * DataOutputStream.
+ *
+ * @param os write the value here
+ * @throws IOException
+ */
+ public void writeUntagged(DataOutputStream os)
+ throws IOException
+ {
+ write(os);
+ }
+
+ /**
+ * Will write the given object as a tagged value to the DataOutputStream.
+ *
+ * @param os write the value here
+ * @param obj the Object to write
+ * @throws IOException
+ */
+ public void writeTagged(DataOutputStream os)
+ throws IOException
+ {
+ os.write (_tag);
+ write(os);
+ }
+
+ /**
+ * This method must write the value to the DataOutputStream in a manner
+ * appropriate for the type of the value.
+ *
+ * @param os DataOutputStream to write to
+ * @throws IOException
+ */
+ protected abstract void write(DataOutputStream os)
+ throws IOException;
+
+ /**
+ * Returns an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ protected abstract Object getObject();
+
+ /**
+ * Get an untagged object from the ByteBuffer
+ *
+ * @param bb the ByteBuffer to extract the value from
+ * @param type a Class representing the type
+ * @return an Object from the ByteBuffer of the type of the Class parameter
+ * @throws JdwpInternalErrorException
+ * @throws InvalidObjectException
+ */
+ public static Object getUntaggedObject(ByteBuffer bb, Class type)
+ throws JdwpInternalErrorException, InvalidObjectException, InvalidClassException
+ {
+ Value val = ValueFactory.createFromUntagged(bb, type);
+ return val.getObject();
+ }
+
+ /**
+ * Get an untagged object from the ByteBuffer
+ *
+ * @param bb the ByteBuffer to extract the value from
+ * @param tag a byte tag representing the type
+ * @return an Object from the ByteBuffer of the type of the Class parameter
+ * @throws JdwpInternalErrorException
+ * @throws InvalidObjectException
+ */
+ public static Object getTaggedObject(ByteBuffer bb)
+ throws JdwpInternalErrorException, InvalidObjectException, InvalidTagException
+ {
+ Value val = ValueFactory.createFromTagged(bb);
+ return val.getObject();
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/ValueFactory.java b/libjava/classpath/gnu/classpath/jdwp/value/ValueFactory.java
new file mode 100644
index 0000000..8f1a878
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/ValueFactory.java
@@ -0,0 +1,247 @@
+/* ValueFactory.java -- factory to create JDWP Values
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.exception.InvalidClassException;
+import gnu.classpath.jdwp.exception.InvalidObjectException;
+import gnu.classpath.jdwp.exception.InvalidTagException;
+import gnu.classpath.jdwp.exception.JdwpInternalErrorException;
+import gnu.classpath.jdwp.id.ObjectId;
+import gnu.classpath.jdwp.util.JdwpString;
+
+import java.nio.ByteBuffer;
+
+/**
+ * A factory to create JDWP Values.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public class ValueFactory
+{
+ /**
+ * Creates a new Value of appropriate type for the value in the ByteBuffer
+ * by reading the tag byte from the front of the buffer.
+ *
+ * @param bb contains the Object
+ * @return A new Value of appropriate type
+ * @throws JdwpInternalErrorException
+ * @throws InvalidObjectException
+ */
+ public static Value createFromTagged(ByteBuffer bb)
+ throws JdwpInternalErrorException, InvalidObjectException, InvalidTagException
+ {
+ return create(bb, bb.get());
+ }
+
+ /**
+ * Creates a new Value of appropriate type for the value in the ByteBuffer
+ * by checking the type of the Class passed in.
+ *
+ * @param bb contains the Object
+ * @param type a Class representing the type of the value in the ByteBuffer
+ * @return A new Value of appropriate type
+ * @throws JdwpInternalErrorException
+ * @throws InvalidObjectException
+ */
+ public static Value createFromUntagged(ByteBuffer bb, Class type)
+ throws JdwpInternalErrorException, InvalidObjectException, InvalidClassException
+ {
+ byte tag = getTagForClass(type);
+
+ try
+ {
+ return create(bb, tag);
+ }
+ catch (InvalidTagException ite)
+ {
+ throw new InvalidClassException(ite);
+ }
+ }
+
+ /**
+ * Creates a new Value of appropriate type for the value in the ByteBuffer.
+ *
+ * @param bb contains the Object
+ * @param tag a byte representing the type of the object
+ * @return A new Value of appropriate type
+ * @throws JdwpInternalErrorException
+ * @throws InvalidObjectException
+ */
+ private static Value create(ByteBuffer bb, byte tag)
+ throws JdwpInternalErrorException, InvalidObjectException, InvalidTagException
+ {
+ Value val = null;
+ switch(tag)
+ {
+ case JdwpConstants.Tag.BYTE:
+ val = new ByteValue(bb.get());
+ break;
+ case JdwpConstants.Tag.BOOLEAN:
+ val = new BooleanValue((bb.get() != 0));
+ break;
+ case JdwpConstants.Tag.CHAR:
+ val = new CharValue(bb.getChar());
+ break;
+ case JdwpConstants.Tag.SHORT:
+ val = new ShortValue(bb.getShort());
+ break;
+ case JdwpConstants.Tag.INT:
+ val = new IntValue(bb.getInt());
+ break;
+ case JdwpConstants.Tag.FLOAT:
+ val = new FloatValue(bb.getFloat());
+ break;
+ case JdwpConstants.Tag.LONG:
+ val = new LongValue(bb.getLong());
+ break;
+ case JdwpConstants.Tag.DOUBLE:
+ val = new DoubleValue(bb.getDouble());
+ break;
+ case JdwpConstants.Tag.VOID:
+ val = new VoidValue();
+ break;
+ case JdwpConstants.Tag.ARRAY:
+ case JdwpConstants.Tag.THREAD:
+ case JdwpConstants.Tag.OBJECT:
+ case JdwpConstants.Tag.THREAD_GROUP:
+ case JdwpConstants.Tag.CLASS_LOADER:
+ case JdwpConstants.Tag.CLASS_OBJECT:
+ ObjectId oid = VMIdManager.getDefault().readObjectId(bb);
+ val = new ObjectValue(oid.getObject());
+ break;
+ case JdwpConstants.Tag.STRING:
+ val = new StringValue(JdwpString.readString(bb));
+ break;
+ default:
+ throw new InvalidTagException(tag);
+ }
+
+ return val;
+ }
+
+ /**
+ * Creates a tag for the type of the class.
+ *
+ * @param klass the type to get a tag for
+ * @return a byte tag representing the class
+ * @throws JdwpInternalErrorException
+ * @throws InvalidObjectException
+ */
+ private static byte getTagForClass(Class klass)
+ throws JdwpInternalErrorException
+ {
+ byte tag;
+
+ if (klass.isPrimitive())
+ {
+ if (klass == byte.class)
+ tag = JdwpConstants.Tag.BYTE;
+ else if (klass == boolean.class)
+ tag = JdwpConstants.Tag.BOOLEAN;
+ else if (klass == char.class)
+ tag = JdwpConstants.Tag.CHAR;
+ else if (klass == short.class)
+ tag = JdwpConstants.Tag.SHORT;
+ else if (klass == int.class)
+ tag = JdwpConstants.Tag.INT;
+ else if (klass == float.class)
+ tag = JdwpConstants.Tag.FLOAT;
+ else if (klass == long.class)
+ tag = JdwpConstants.Tag.LONG;
+ else if (klass == double.class)
+ tag = JdwpConstants.Tag.DOUBLE;
+ else if (klass == void.class)
+ tag = JdwpConstants.Tag.VOID;
+ else
+ throw new JdwpInternalErrorException("Invalid primitive class");
+ }
+ else
+ {
+ tag = JdwpConstants.Tag.OBJECT;
+ }
+
+ return tag;
+ }
+
+ /**
+ * Create a value type for an Object of type determined by a Class. This is
+ * a special case where a value needs to be created, but the value to create
+ * it for is already in an object, not in a buffer.
+ *
+ * @param value the Object to convert to a Value
+ * @param type the Class type of the object
+ * @return a new Value representing this object
+ */
+ public static Value createFromObject(Object value, Class type)
+ {
+ Value val = null;
+
+ if (type.isPrimitive())
+ {
+ if (type == byte.class)
+ val = new ByteValue(((Byte) value).byteValue());
+ else if (type == boolean.class)
+ val = new BooleanValue(((Boolean) value).booleanValue());
+ else if (type == char.class)
+ val = new CharValue(((Character) value).charValue());
+ else if (type == short.class)
+ val = new ShortValue(((Short) value).shortValue());
+ else if (type == int.class)
+ val = new IntValue(((Integer) value).intValue());
+ else if (type == float.class)
+ val = new FloatValue(((Float) value).floatValue());
+ else if (type == long.class)
+ val = new LongValue(((Long) value).longValue());
+ else if (type == double.class)
+ val = new DoubleValue(((Double) value).doubleValue());
+ else if (type == void.class)
+ val = new VoidValue();
+ }
+ else
+ {
+ if (type.isAssignableFrom(String.class))
+ val = new StringValue ((String) value);
+ else
+ val = new ObjectValue(value);
+ }
+
+ return val;
+ }
+}
diff --git a/libjava/classpath/gnu/classpath/jdwp/value/VoidValue.java b/libjava/classpath/gnu/classpath/jdwp/value/VoidValue.java
new file mode 100644
index 0000000..82cded9
--- /dev/null
+++ b/libjava/classpath/gnu/classpath/jdwp/value/VoidValue.java
@@ -0,0 +1,82 @@
+/* VoidValue.java -- JDWP wrapper class for a void value
+ Copyright (C) 2007 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.jdwp.value;
+
+import gnu.classpath.jdwp.JdwpConstants;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+/**
+ * Wrapper for an void value.
+ *
+ * @author Kyle Galloway <kgallowa@redhat.com>
+ */
+public class VoidValue
+ extends Value
+{
+ /**
+ * Create a new VoidValue.
+ */
+ public VoidValue ()
+ {
+ super(JdwpConstants.Tag.VOID);
+ }
+
+ /**
+ * Return an object representing this type
+ *
+ * @return an Object represntation of this value
+ */
+ @Override
+ protected Object getObject()
+ {
+ return null;
+ }
+
+ /**
+ * Write the wrapped void to the given DataOutputStream.
+ *
+ * @param os the output stream to write to
+ */
+ @Override
+ protected void write(DataOutputStream os)
+ throws IOException
+ {
+ }
+}