RFR: JDK-8280168 Add Objects.toDefaultString [v6]
Alan Bateman
alanb at openjdk.java.net
Mon Jan 24 19:22:10 UTC 2022
On Sat, 22 Jan 2022 19:29:45 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>> While it is strongly recommend to not use the default toString for a class, at times it is the least-bad alternative. When that alternative needs to be used, it would be helpful to have the implementation already available, such as in Objects.toDefaultString(). This method is analagous to System.identityHashCode.
>>
>> Please also review the CSR: https://bugs.openjdk.java.net/browse/JDK-8280184
>
> Joe Darcy has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
>
> - Merge branch 'master' into JDK-8280168
> - Appease jcheck.
> - Add toIdentityString
> - Respond to review feedback to augment test.
> - Respond to review feedback.
> - JDK-8280168 Add Objects.toDefaultString
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().
-------------
PR: https://git.openjdk.java.net/jdk/pull/7139
More information about the core-libs-dev
mailing list