BTW, here's my temporary workaround:
private class FixedHashMap extends HashMap {
protected boolean _inHashCode = false;
@Override
public int hashCode() {
int result = 0;
if (_inHashCode ) { return result; }
_inHashCode = true;
result = super.hashCode();
_inHashCode = false;
return result;
}
}
On Jan 2, 8:37 pm, sinelaw <[email protected]> wrote:
> Problem can be reproduced with four lines of code:
>
> HashMap<String,Object> testMap = new HashMap<String,
> Object>();
> testMap.put("me", testMap);
> HashMap<Object,Object> testMap2 = new HashMap<Object,
> Object>();
> testMap2.put(testMap, null); // <---- causes a stack overflow.
>
> The problem is in the following line of HashMap.hashCode():> result +=
> keyHashCode(unmaskNullKey(key)) ^ valueHashCode(values[i]);
>
> since value[i] could equal this (the current instance), valueHashCode
> will recurse into hashCode causing an infinite recursion and stack
> overflow. It can be fixed by not calling valueHashCode on values that
> are this instance.
>
> Is this a bug or a "feature"?
>
> Thanks!
>
> EntireOne, Inc.
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors