Equals and inheritance - uneasy relationship. According to Joshua Bloch "there is no way to extend an instantiable class and add a value component while preserving the equals contract" (page 38, Effective Java, item 8) This test is the prove.
This equals() implementation is generated by Eclipse (with minor names alterations)
Problem is Point does not know about extra field in ColorPoint, so from its perspective they are equal, but from ColorPoint they are not - broken symmetry.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.