A HashMap bug with a Proxy value?

Jing LV lvjing at linux.vnet.ibm.com
Wed Jan 12 15:53:26 UTC 2011

Hello everyone,

(As I am new in OpenJDK, please tell me if I post on the wrong
I find an odd behaviour of HashMap. If we put a value which is an
instance of Proxy, it would return false while checking
containsValue(proxyinstance). I checked use Proxy instance as a key, it
works well.
I suppose this is a bug of HashMap. By reading the code closely, I find
the problem was that, for Proxy instance, Proxy.equals(Proxy) may return
false (there are many discussions on this already).
HashMap.containsKey() will check if there is a key in the map equals
and/or the same with the given key(so it bypass equals check) with
getEntry() method but HashMap.containsValue() does not. So a quick fix
will be: check there is a value in the map that equals and/or the same
with the given value.

I'd like to report this bug to bugzilla of openjdk, with my testcase and
patch. Please tell me if any comments. Thanks a lot.

Best wishes!
Jing LV

More information about the core-libs-dev mailing list