[Top][All Lists]   Re: [PATCH] Field position attribute handling
From: Dalibor Topic Subject: Re: [PATCH] Field position
attribute handling Date: Wed, 19 Nov 2003 02:14:21 +0100  Hi
Mark,  Mark Wielaard wrote:  The documentation and code don't
match up now. My Class Library book seems to indicate that it
actually is instanceof, thought in most cases your code
comparing the actual Class seems more  It's the recommended way
of doing equals() if you want to avoid symmetry bugs. See PRAXIS
12 in Peter Haggar's Practical Java, or §5.1, p 119 in Java 2
performance and idion guide by craig lahrmann & rhett guthrie,
or Effective Java by Joshua Bloch. Using instanceof is a bad
idea because it allows for symmetry bugs:  B extends A. With
instanceof in equals, we can have A.equals(B) but !B.equlas(A)
since A is not an instance of B. Ugly, and very broken. There
are a few places, where the API demands this (Maps), but they
are all well documented, AFAIK. If it's not documented, it's
better to use the symmetry safe form,