This looks correct. I appreciate the toString() method with a unique result.
Mike On Jan 9 2012, at 17:05 , Neil Richards wrote: > Hi all, > When proposing the change for 6312706 [1], 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) [2]. > > 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 [3], 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, > Thanks, > Neil > > [1] http://hg.openjdk.java.net/jdk7/tl/jdk/rev/c1e87a18e46a > [2] > http://mail.openjdk.java.net/pipermail/core-libs-dev/2011-March/006353.html > [3] 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 >