summaryrefslogtreecommitdiff
path: root/gnu/classpath
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2006-03-16 01:01:17 +0000
committerKeith Seitz <keiths@redhat.com>2006-03-16 01:01:17 +0000
commit17929cd9ffe9411507128e1a08e599046e136eb0 (patch)
tree3564088767c33aecad71814a803c46880191f2ef /gnu/classpath
parent46889f19f788627d8719561b402bb3b129fa6e45 (diff)
downloadclasspath-17929cd9ffe9411507128e1a08e599046e136eb0.tar.gz
* gnu/classpath/jdwp/util/Location.java: Rewrite using VMMethod.
(Location): Index is a long, not an int. (getMethod): New method. (getIndex): New method. (toString): New method.
Diffstat (limited to 'gnu/classpath')
-rw-r--r--gnu/classpath/jdwp/util/Location.java88
1 files changed, 53 insertions, 35 deletions
diff --git a/gnu/classpath/jdwp/util/Location.java b/gnu/classpath/jdwp/util/Location.java
index d7a2855ce..005b12c2b 100644
--- a/gnu/classpath/jdwp/util/Location.java
+++ b/gnu/classpath/jdwp/util/Location.java
@@ -1,5 +1,5 @@
/* Location.java -- class to read/write JDWP locations
- Copyright (C) 2005 Free Software Foundation
+ Copyright (C) 2005, 2006 Free Software Foundation
This file is part of GNU Classpath.
@@ -39,13 +39,12 @@ exception statement from your version. */
package gnu.classpath.jdwp.util;
import gnu.classpath.jdwp.VMIdManager;
+import gnu.classpath.jdwp.VMMethod;
import gnu.classpath.jdwp.exception.JdwpException;
import gnu.classpath.jdwp.id.ClassReferenceTypeId;
-import gnu.classpath.jdwp.id.ObjectId;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.lang.reflect.Method;
import java.nio.ByteBuffer;
/**
@@ -55,62 +54,81 @@ import java.nio.ByteBuffer;
*/
public class Location
{
-
- private ClassReferenceTypeId crti;
-
- private int index;
-
- private byte tag;
-
- private ObjectId mid;
+ private VMMethod method;
+ private long index;
/**
* Create a location with the given parameters.
*
- * @param tag the type of construct the location is in
- * @param clazz the class the location is in
- * @param meth the Method
+ * @param method the method
* @param index location in the method
- * @throws JdwpException
*/
- public Location(byte tag, Class clazz, Method meth, int index)
- throws JdwpException
+ public Location(VMMethod method, long index)
{
- this.tag = tag;
- this.crti =
- (ClassReferenceTypeId) VMIdManager.getDefault().getReferenceTypeId(clazz);
- this.mid = VMIdManager.getDefault().getObjectId(meth);
+ this.method = method;
this.index = index;
}
/**
* Read a location from the given bytebuffer, consists of a TAG (byte),
- * followed by a ReferenceTypeId, a MethodId and an index (int).
+ * followed by a ReferenceTypeId, a MethodId and an index (long).
*
* @param bb this holds the location
- * @throws IOException
- * @throws JdwpException
+ * @throws IOException when an error occurs reading from the buffer
+ * @throws JdwpException for invalid class or method IDs
*/
- public Location(ByteBuffer bb) throws IOException, JdwpException
+ public Location(ByteBuffer bb)
+ throws IOException, JdwpException
{
- this.tag = bb.get();
- this.crti =
+ byte tag = bb.get();
+ ClassReferenceTypeId classId =
(ClassReferenceTypeId) VMIdManager.getDefault().readReferenceTypeId(bb);
- this.mid = VMIdManager.getDefault().readObjectId(bb);
- this.index = bb.getInt();
+ Class klass = classId.getType();
+ method = VMMethod.readId(klass, bb);
+ index = bb.getLong();
}
/**
* Write the given location to an output stream.
*
* @param os stream to write to
- * @throws IOException
+ * @throws IOException when an error occurs writing to the stream
+ */
+ public void write(DataOutputStream os)
+ throws IOException
+ {
+ VMIdManager idm = VMIdManager.getDefault();
+ ClassReferenceTypeId crti = (ClassReferenceTypeId)
+ idm.getReferenceTypeId(method.getDeclaringClass());
+
+ crti.writeTagged(os);
+ method.writeId(os);
+ os.writeLong(index);
+ }
+
+ /**
+ * Gets the method of this location
+ *
+ * @return the method
+ */
+ public VMMethod getMethod()
+ {
+ return method;
+ }
+
+ /**
+ * Gets the code index of this location
+ *
+ * @return the code index
*/
- public void write(DataOutputStream os) throws IOException
+ public long getIndex ()
+ {
+ return index;
+ }
+
+ // convenient for debugging
+ public String toString ()
{
- os.writeByte(tag);
- crti.write(os);
- mid.write(os);
- os.writeInt(index);
+ return method.toString () + "." + index;
}
}