On Tue, 2005-12-27 at 11:14 -0800, Per Bothner wrote:
> Michael Barker wrote:
>   >>From the equals() code, its applicable in this case:
> > 
> >     // The toString output must match.
> >     if (! toString().equals(((KerberosPrincipal)that).toString()))
> >       return false;
> 
> In your message you did phrase things in terms of general contracts.

True, my fault, I jumped context.

> 
> More to the point: Using toString in the implementation of equals
> seems like a bad idea.  The only rationale I can think of is as a
> hack to try to catch that the actual classes match.  But it seems
> an unreliable and inefficient method to do so.
> 
> I'd go further: Implementing equals in terms of toString is a bug.
> One should be able to change toString before better output or
> debuggability without breaking equals.

I agree, and the hashCode() method should follow suite.

Regards,
Michael Barker.



_______________________________________________
Classpath mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to