--- old/src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java 2019-10-15 08:20:25.000000000 -0400 +++ new/src/jdk.jdi/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java 2019-10-15 08:20:25.000000000 -0400 @@ -76,6 +76,10 @@ } } + private boolean isInlineType() { + return referenceType().signature().startsWith("Q"); + } + // Override in subclasses protected Cache newCache() { return new Cache(); @@ -145,11 +149,31 @@ } } + private boolean isSubstitutable(ObjectReferenceImpl other) { + if (referenceType() != other.referenceType()) return false; + List fields = referenceType().fields(); + for (Field f : fields) { + if (f.isStatic()) { + fields.remove(f); + } + } + Map thisFields = getValues(fields); + Map 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; - return (ref() == other.ref()) && - super.equals(obj); + ObjectReferenceImpl other = (ObjectReferenceImpl) obj; + if (isInlineType()) { + return isSubstitutable(other); + } else { + return (ref() == other.ref()) && + super.equals(obj); + } } else { return false; } @@ -470,6 +494,9 @@ } public long uniqueID() { + if (isInlineType()) { + throw new UnsupportedOperationException("Inline types cannot have unique IDs"); + } return ref(); } @@ -594,6 +621,10 @@ (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"); } @@ -611,11 +642,19 @@ } public String toString() { - return "instance of " + referenceType().name() + "(id=" + uniqueID() + ")"; + if (isInlineType()) { + return "instance of " + referenceType().name(); + } else { + return "instance of " + referenceType().name() + "(id=" + uniqueID() + ")"; + } } byte typeValueKey() { - return JDWP.Tag.OBJECT; + if (isInlineType()) { + return JDWP.Tag.INLINE_OBJECT; + } else { + return JDWP.Tag.OBJECT; + } } private static boolean isNonVirtual(int options) {