< prev index next >

src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java

Print this page

        

@@ -74,10 +74,14 @@
         synchronized (vm.state()) {
             cache = markerCache;
         }
     }
 
+    private boolean isInlineType() {
+        return referenceType().signature().startsWith("Q");
+    }
+
     // Override in subclasses
     protected Cache newCache() {
         return new Cache();
     }
 

@@ -143,15 +147,36 @@
                 return true;
             }
         }
     }
 
+    private boolean isSubtituable(ObjectReferenceImpl other) {
+        if (referenceType() != other.referenceType()) return false;
+        List<Field> fields = referenceType().fields();
+        for (Field f : fields) {
+            if (f.isStatic()) {
+                fields.remove(f);
+            }
+        }
+        Map<Field,Value> thisFields = getValues(fields);
+        Map<Field,Value> otherFields = other.getValues(fields);
+        for (Field f : fields) {
+            if (!thisFields.get(f).equals(otherFields.get(f))) return false;
+        }
+        return true;
+    }
+
     public boolean equals(Object obj) {
         if ((obj != null) && (obj instanceof ObjectReferenceImpl)) {
-            ObjectReferenceImpl other = (ObjectReferenceImpl)obj;
+            ObjectReferenceImpl other = (ObjectReferenceImpl) obj;
+            if (isInlineType()) {
+                return isSubtituable(other);
+
+            } else {
             return (ref() == other.ref()) &&
                    super.equals(obj);
+            }
         } else {
             return false;
         }
     }
 

@@ -468,10 +493,13 @@
             throw exc.toJDIException();
         }
     }
 
     public long uniqueID() {
+        if (isInlineType()) {
+            throw new UnsupportedOperationException("Inline types cannot have unique IDs");
+        }
         return ref();
     }
 
     JDWP.ObjectReference.MonitorInfo jdwpMonitorInfo()
                              throws IncompatibleThreadStateException {

@@ -609,12 +637,16 @@
                                            " to " + destTypeName);
         }
     }
 
     public String toString() {
+        if (isInlineType()) {
+            return "instance of " + referenceType().name();
+        } else {
         return "instance of " + referenceType().name() + "(id=" + uniqueID() + ")";
     }
+    }
 
     byte typeValueKey() {
         return JDWP.Tag.OBJECT;
     }
 
< prev index next >