Request for review: 7123229: (coll) EnumMap.containsValue(null) returns true (original) (raw)

Alan Bateman Alan.Bateman at oracle.com
Tue Jan 24 10:15:06 UTC 2012


Neil - are you still planning to push this to jdk8/tl? As it's regression, albeit small, it seems like a good candidate for jdk7u too.

-Alan.

On 10/01/2012 01: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/



More information about the core-libs-dev mailing list