[erlang-patches] [jinterface] added OtpMbox.hash()

Gábor Lipták <>
Wed Sep 22 23:19:51 CEST 2010


OtpErlangPid currently does not implement hashCode() , so forwarding
from OtpMbox to OtpErlangPid still might not define identity
correctly. As OtpErlangPid overrides equals(), it should also have
hashCode() implemented.

Please see discussion on this at
http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf

On Tue, Sep 21, 2010 at 05:51, Raimo Niskanen
<> wrote:
> On Mon, Sep 20, 2010 at 07:11:51PM +0200, Vlad Dumitrescu wrote:
>> On Mon, Sep 20, 2010 at 17:10, Raimo Niskanen
>> <> wrote:
>> > Excuse me for a maybe stupid question...
>> >
>> > Why is it necessary?
>> >
>> > Calling self.hashCode() from a class inheriting from Object
>> > should be done through inheritance without the patch.
>> >
>> > Is there some tool complaining if both are not overridden
>> > even if the result is correct (or is it not?), or have
>> > have the rules changed since the old days, or am
>> > I missing something?...
>>
>> Not a stupid question, but almost every static analysis tool complains
>> about this.
>>
>> In any case, the patch calls self.hash(), not super.hash(). Whatever
>> is compared in equals() should be included when computing the hash.
>
> Thank you, now I see the light! I have been programming Erlang too
> long and mistook 'self' with 'this'...
>
> So the current inherited hashCode() function is incorrect
> in calling super.hashCode(). We will take the patch as it is,
> a test case seems to be not worth the trouble.


More information about the erlang-patches mailing list