DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17987>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17987

Subclassing is broken

           Summary: Subclassing is broken
           Product: Commons
           Version: 1.0 Alpha
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Lang
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Add the following to EqualsBuilderTest:

    public void testSubclassing()
    {
        TestObject to2 = new TestObject(5);
        TestObject to1Ter = new TestSubObject(4, 10);
        TestObject to1Bis = new TestSubObject(4, 10);
        TestObject to1 = new TestObject(4);
        testReflectionEqualsEquivalenceRelationship(to1, to1Bis, to1Ter, to2,
new TestObject(), false);
    }

As you can see, the whole concept behind appendSuper
and such produces equals methods which are not symmetric
and thus do not fulfill the equals contract.

The two general solutions I'm aware of are: (1) Make the equals
method final, so that subclasses are required to all
use the same equals method as each other and the superclass,
or (2) Use foo.getClass() == bar.getClass() instead
of instanceOf, so that an instance of the superclass is
never equals to an instance of a subclass.

In particular situations there might be specific solutions (look at
the way equals is defined for List and Set for example).

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to