< 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,35 @@
return true;
}
}
}
+ private boolean isSubstitutable(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 isSubstitutable(other);
+ } else {
return (ref() == other.ref()) &&
super.equals(obj);
+ }
} else {
return false;
}
}
@@ -468,10 +492,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 {
@@ -592,10 +619,14 @@
}
if ((destination.signature().charAt(0) == '[') &&
(type().signature().charAt(0) != '[')) {
throw new InvalidTypeException("Can't assign non-array value to an array");
}
+ if ((destination.signature().charAt(0) == 'Q') &&
+ ref() == 0) {
+ throw new InvalidTypeException("Can't assign null value to an inline type");
+ }
if ("void".equals(destination.typeName())) {
throw new InvalidTypeException("Can't assign object value to a void");
}
// Validate assignment
@@ -609,16 +640,24 @@
" to " + destTypeName);
}
}
public String toString() {
+ if (isInlineType()) {
+ return "instance of " + referenceType().name();
+ } else {
return "instance of " + referenceType().name() + "(id=" + uniqueID() + ")";
}
+ }
byte typeValueKey() {
+ if (isInlineType()) {
+ return JDWP.Tag.INLINE_OBJECT;
+ } else {
return JDWP.Tag.OBJECT;
}
+ }
private static boolean isNonVirtual(int options) {
return (options & INVOKE_NONVIRTUAL) != 0;
}
}
< prev index next >