8280168: Add Objects.toIdentityString

Reviewed-by: alanb, mchung, rriggs, smarks
This commit is contained in:
Joe Darcy 2022-01-25 18:15:37 +00:00
parent f4575e4052
commit cbe8395ace
3 changed files with 60 additions and 5 deletions

View file

@ -292,7 +292,7 @@ public class MethodHandleProxies {
private static Object callObjectMethod(Object self, Method m, Object[] args) {
assert(isObjectMethod(m)) : m;
return switch (m.getName()) {
case "toString" -> self.getClass().getName() + "@" + Integer.toHexString(self.hashCode());
case "toString" -> java.util.Objects.toIdentityString(self);
case "hashCode" -> System.identityHashCode(self);
case "equals" -> (self == args[0]);
default -> null;