Hello everyone, (As I am new in OpenJDK, please tell me if I post on the wrong mailing-list). 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