I stumbled across the issue with TObjectDoubleHashMap of trove. The version 2.0.2 doesn’t override the hashCode method.
More recent versions of trove (3.0.0) include the hashCode.
Note, that the equals method is overriden in both versions.
Why wasn’t the hashCode method overriden in the version 2? Maybe the contract for overriding hashCode/equals was introduced after the trove maps were written originally? Or is it simply a violation of the contract and a bug that was fixed later? I’d be very surprised if it’s a bug and not a feature, because how come the class that mostly deals with hashing not override hashCode when it has equals
No. That was present way back. I believe at least as early as 1.1, but I can’t find anything earlier than 1.3 docs.
Yes. It is a violation of the contract. Note that
java.util.Maphas its own extra equality/hashCode contract above and beyondjava.lang.Object, which is knowingly violated byIdentityHashMapand a few others.From the javadoc: