Request for review: 7123229: (coll) EnumMap.containsValue(null) returns true
mike.duigou at oracle.com
Mon Jan 9 19:43:58 PST 2012
This looks correct. I appreciate the toString() method with a unique result.
On Jan 9 2012, at 17:05 , Neil Richards wrote:
> Hi all,
> When proposing the change for 6312706 , I erroneously managed to
> convince myself (and others!) that it would be safe to use 'new
> Integer(0)' for java.util.EnumMap.NULL (the object used to mark null
> values for entries in the map) .
> This was on the basis that I thought it was only compared by identity.
> However, on closer inspection, this turns out not to be the case.
> 7123229 was raised to report the bug that was introduced based on this
> invalid assumption.
> I've created a webrev with a suggested fix for 7123229 , which
> changes NULL to be an Object which:
> * will only return 'true' from equals(Object) for itself
> * returns 0 from hashCode()
> For good measure, it also returns a sensible value from toString().
> Please review this fix and let me know your thoughts,
>  http://hg.openjdk.java.net/jdk7/tl/jdk/rev/c1e87a18e46a
>  http://mail.openjdk.java.net/pipermail/core-libs-dev/2011-March/006353.html
>  http://cr.openjdk.java.net/~ngmr/7123229/webrev.00/
> Unless stated above:
> IBM email: neil_richards at uk.ibm.com
> IBM United Kingdom Limited - Registered in England and Wales with number 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
More information about the core-libs-dev