OSDN Git Service

2006-08-14 Mark Wielaard <mark@klomp.org>
[pf3gnuchains/gcc-fork.git] / libjava / classpath / gnu / classpath / jdwp / util / Location.java
index 005b12c..89e81e5 100644 (file)
@@ -94,18 +94,40 @@ public class Location
    * @param os stream to write to
    * @throws IOException when an error occurs writing to the stream
    */
-  public void write(DataOutputStream os)
+  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);
+    // check if this is an empty location
+    if (method != null)
+      {
+        VMIdManager idm = VMIdManager.getDefault();
+        ClassReferenceTypeId crti = 
+          (ClassReferenceTypeId) 
+          idm.getReferenceTypeId(method.getDeclaringClass());
+
+        crti.writeTagged(os);
+        method.writeId(os);
+        os.writeLong(index);
+      }
+    else
+      {
+        os.writeByte(1);
+        os.writeLong((long) 0);
+        os.writeLong((long) 0);
+        os.writeLong((long) 0);
+      }
   }
-
+  
+  /**
+   * Sets up an empty location
+   * 
+   * @return new Location (setup as empty)
+   */
+  public static Location getEmptyLocation()
+  {
+       return new Location(null, 0);
+  }
+   
   /**
    * Gets the method of this location
    *