This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/JDWP] Fix ReferenceType.ClassLoader


Whenever this operation was attempted with a class loaded by the boot class loader, the null value would crash the communication thread causing the VM to stop responding to debugger commands. This patch, the contents of which are already in the reference implementation in Classpath, properly returns NullObjectIds which avoids the crash and allows the debugger to continue correctly. It also will correctly return a NullObjectId if get is called with id = 0.

ChangeLog
2007-04-11  Kyle Galloway  <kgallowa@redhat.com>

* gnu/classpath/jdwp/VMIdManager.java (getObjectId): Deal with null objects.
(get): Deal with ObjectId of 0.


Questions/comments/concerns?

Thanks,
Kyle
Index: gnu/classpath/jdwp/VMIdManager.java
===================================================================
--- gnu/classpath/jdwp/VMIdManager.java	(revision 123715)
+++ gnu/classpath/jdwp/VMIdManager.java	(working copy)
@@ -1,7 +1,7 @@
 /* VMIdManager.java -- A reference/example implementation of a manager for
    JDWP object/reference type IDs
 
-   Copyright (C) 2005, 2006 Free Software Foundation
+   Copyright (C) 2005, 2006, 2007 Free Software Foundation
 
 This file is part of GNU Classpath.
 
@@ -337,6 +337,10 @@
    */
   public ObjectId getObjectId (Object theObject)
   {
+    // Special case: null object.
+    if (theObject == null)
+      return new NullObjectId ();
+	  
     ReferenceKey ref = new ReferenceKey (theObject, _refQueue);
     ObjectId id = (ObjectId) _oidTable.get (ref);
     if (id == null)
@@ -364,6 +368,10 @@
   public ObjectId get (long id)
     throws InvalidObjectException
   {
+    // Special case: null object id.
+    if (id == 0)
+      return new NullObjectId ();
+    
     ObjectId oid = (ObjectId) _idTable.get (new Long (id));
     if (oid == null)
       throw new InvalidObjectException (id);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]