RFR: JDK-8280168 Add Objects.toDefaultString [v2]

Joe Darcy darcy at openjdk.java.net
Wed Jan 19 02:57:12 UTC 2022


On Wed, 19 Jan 2022 02:22:33 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Joe Darcy has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Respond to review feedback.
>
> src/java.base/share/classes/java/util/Objects.java line 170:
> 
>> 168:      * {@return a string equivalent to the string returned by {@code
>> 169:      * Object.toString} if that method is not overridden}
>> 170:      *
> 
> The original Object.toString() invokes the hashCode() method.
> Perhaps the spec should indicate that it calls IdentityhashCode() instead of hashCode().
> 
> Though not incorrect, in Valhalla, Not all objects have identity and will need to different implementation.
> 
> Are there any use cases in the JDK that will use this method?

I updated the return statement to say if hashCode isn't overridden either. The implSpec tag does explicitly mention identityHashCode already.

There are a few instances of this sort of code in the JDK src directory already; I may include a refactoring of at least one of them in a future revision of the PR. Thanks.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7139


More information about the core-libs-dev mailing list