[concurrency-interest] Reference/IdentityMap toString

Jason Mehrens jason_mehrens at hotmail.com
Thu Aug 19 11:25:09 EDT 2010

> You still haven't come up with any convincing use case. 
Feel free to counter each of my previous points.
>I've never seen any bugs related to this behavior. 
Take the output of this code:
Map<Integer, Integer> id = new IdentityHashMap<Integer, Integer>();
id.put(new Integer(1), new Integer(1));
id.put(new Integer(1), new Integer(1));
id.put(new Integer(1), new Integer(1));
Shouldn't a set contain unique items? If you are tracking items by identity or reference displaying the contents of a key/value has no meaning.  I don't think I would get any positive feedback if I wrote the output of that code on a piece of paper and presented it as an example of a unique set of elements.
>And if you want a custom toString 
> method for CCHM you can just use the CCHM.entrySet().iterator to iterate 
> through all elements and print whatever you want. 
That applies both ways.
>Requiring people to 
> implement a toString(Object) method whenever they implement the 
> Equivalence interface is just a waste of peoples time IMO.
Equivalence is extracting methods from Object.  The object documentation states they subclasses should always override toString.  Currently, there is no way translate that requirement from Object to Equivalence.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20100819/b53b5cd6/attachment-0001.html>

More information about the Concurrency-interest mailing list