[concurrency-interest] Reference/IdentityMap toString

Tim Peierls tim at peierls.net
Fri Aug 20 16:18:27 EDT 2010


On Fri, Aug 20, 2010 at 2:08 PM, Jason Mehrens <jason_mehrens at hotmail.com>wrote:

> [Tim wrote:] While bijectivity is an attractive property for a string
> representation function, it's not something anyone should depend on.
>
> [Jason wrote:] Agreed.  A key toString implementation lacking sufficient
> detail could cause AbstractMap.toString to lose that property (at no fault
> of the map).
>

I meant that because no one should be depending on toString being bijective,
there's not much point in striving for bijectivity in toString
implementations in the first place. So I don't think AbstractMap.toString()
can be fairly described as "broken", even for identity maps.

As others have mentioned, if you have a specific need to preserve a key's
identity in a string representation -- e.g., debugging, logging -- there are
several approaches one could use that don't involve complicating
AbstractMap.toString.

--tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20100820/618ba2fb/attachment.html>


More information about the Concurrency-interest mailing list