I have a suggestion for how to fix this. First, I want to point out a problem 
with a proposed fix by a previous poster. The suggestion was:

One potential fix could be to have another else if branch to check if two 
classes share a common superclass.

As I mentioned on the bug page, this wouldn't have worked on a past project of 
mine. All our entity beans shared a common base class, which implemented 
equals() by using reflectionEquals(). This way, all our entities got an 
equals() method for free. Any two entities of different classes would be seen 
as not equal. But if we implement the proposed fix, then any two entities of 
different classes would now be equal. This doesn't seem like a good idea.

Here's another idea. Allow the user to specify which parent class to use for 
doing the comparison. So, for the revised test case, the call to 
reflectionEquals() might look more like this:  return 
EqualsBuilder.reflectionEquals(C.class, this, other);

The hazard here is that there are other overloaded methods that take a Class 
instance to specify the reflectUpTo property. We would need to design the API 
to reduce the likelihood that these two parameter could get confused.

-- Miguel Munoz

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to