RFR: JDK-8280168: Add Objects.toIdentityString [v6]
Joe Darcy
darcy at openjdk.java.net
Mon Jan 24 21:33:12 UTC 2022
On Mon, 24 Jan 2022 19:56:55 GMT, Stuart Marks <smarks at openjdk.org> wrote:
> I'm wondering if we want to have `toDefaultString` at all, and whether we should have just `toIdentityString`. The primary use case, it seems to me, is the ability to get a string representation for some object, without involving any code in that object itself. There are the collections with cycles that I mentioned previously (in comments on the CSR), for which there is no well-defined hashCode. There is also the case that when logging mutable objects, the hashCode can change over time. This makes it difficult to analyze a log file and track what happens to a particular object. (I know I've been confused by this phenomenon in the past.) Thus `toDefaultString` doesn't seem all that useful to me.
>
> It may be that the current use cases in the JDK can be replaced with `toDefaultString` but not `toIdentityString` without changing their behavior. But maybe we should consider changing their behavior and use `toIdentityString` instead.
Updated the PR to just have toIdentityString and make corresponding changes to the CSR.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7139
More information about the core-libs-dev
mailing list