xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Pepping <spepp...@leverkruid.eu>
Subject Re: [VOTE] Merge XGC color branch into Trunk
Date Tue, 02 Nov 2010 20:40:34 GMT
On Tue, Nov 02, 2010 at 09:17:35PM +0100, Simon Pepping wrote:
> On Mon, Nov 01, 2010 at 08:29:14PM +0000, Vincent Hennebert wrote:
> 
> > Either ColorWithAlternatives is not a Color and therefore should not
> > extend the Color class; or its equals method should be changed to follow
> > the contract and the comparison of ColorWithAlternatives instances
> > should be implemented differently.
> 
> Would findbugs find this problem?

It does:

equals method overrides equals in superclass and may not be symmetric

This class defines an equals method that overrides an equals method in
a superclass. Both equals methods methods use instanceof in the
determination of whether two objects are equal. This is fraught with
peril, since it is important that the equals method is symmetrical (in
other words, a.equals(b) == b.equals(a)). If B is a subtype of A, and
A's equals method checks that the argument is an instanceof A, and B's
equals method checks that the argument is an instanceof B, it is quite
likely that the equivalence relation defined by these methods is not
symmetric.

Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Mime
View raw message