On Mon, 24 Jan 2022 21:27:06 GMT, Joe Darcy <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java line
>> 295:
>>
>>> 293: assert(isObjectMethod(m)) : m;
>>> 294: return switch (m.getName()) {
>>> 295: case "toString" -> java.util.Objects.toDefaultString(self);
>>
>> It might be better if toString is changed to invoke toIdentityString(self),
>> only because hashCode returns the identity hash code, it doesn't invoke
>> hashCode().
>
> Yes; that looks like an inconsistency/bug. Updated in a subsequent push.
Yes, it's a bug and it should call the one with identity hash code. The
`toString` method of a Proxy instance should return the result of the default
implementation of `Object::toString` method as specified.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7139