Adam Lally wrote:
On Jan 31, 2008 11:09 AM, Thilo Goetz <[EMAIL PROTECTED]> wrote:
I think what Adam means is that java.lang.Object implements both
hashCode() and equals() anyway, so declaring them on any interface
makes no difference (because any class will implement it by virtue
of inheritance from java.lang.Object).


Yes, thanks for translating. ;)  All objects implement hashCode() and
equals().  There's no way to force them to do it intelligently. :)

-Adam
Thanks for clarifying ;-) There perhaps is a way to encourage intelligent implementations. Many quality tools (Eclipse refactorings, Findbugs, for instance) do/can check if some class implements equals (thereby making it a reasonable assumption that they're overriding the default impl in Object) without also implementing hashCode; and it would seem reasonable to signal an warning (which is what the Eclipse refactoring code did) when it found one without the other.

-Marshall

Reply via email to