jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Elliot Metsger <emets...@jhu.edu>
Subject Re: Checkstyle improvements
Date Wed, 27 Apr 2005 19:28:44 GMT
Felix Meschberger wrote:
> Hi,
> Just a small clarification...
> Stefan Guggisberg schrieb:
>> regarding missing hashCode(): i intentionally do never override 
>> hashCode()
>> for mutable objects. hashCode() should imo only be implemented for 
>> immutable objects.  
> Unfortunately this is not in line with the general contract of the 
> hashCode and equals methods, which says - amongst other things - that 
> for two objects being equal according to equals the hashCode must be the 
> same. If you do not overwrite the hashCode method whenever you overwrite 
> the equals method, you will get into troubles. Josh Bloch has written a 
> nice text on this issue in his famous book.

yes, you run into problems when inserting objects that override equals() 
but not hashcode() into Set's for example.

View raw message