On 30 Oct 00, at 15:25, Rickard �berg wrote:

> Hi!
>
> Dan OConnor wrote:
> > I think we should simply ensure that equals and hashCode are
> > implemented in a class derived from Object. I don't think we should
> > try to test the functionality of these methods if they exist, as this
> > second test has ample room for mistakes and little upside.
>
> That would be a simpler test, yes.
>
> > The code to do this could involve calling "getDeclaredMethod" on
> > each class object in the inheritance tree until you reached Object
> > (or found an appropriate method). You would travel up the
> > inheritance heirarchy by using getSuperclass.
>
> getMethod is preferred and easier since these two are public methods.

Hi Rickard,

getMethod() will get the method from the class or any superclass.
In the case of equals and hashCode, it will always find an
implementation in java.lang.Object. Hence, it will not work in this
algorithm.

getDeclaredMethod() will only check the class that has been
passed in as a parameter. Because you stop before getting to
java.lang.Object, you avoid a "false positive."

-Dan


>
> /Rickard
>
> --
> Rickard �berg
>
> Email: [EMAIL PROTECTED]
> http://www.telkel.com
> http://www.jboss.org
> http://www.dreambean.com
>
>
>
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]
>




--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to