You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Sian January <si...@googlemail.com> on 2007/01/12 12:34:25 UTC
[classlib] [security] equals method that just returns false
Hello,
I have found a class in the security module that overrides the equals
methods, but just returns false within that method. There doesn't seem to
be any comment about why it does this so I was just wondering if anyone had
any idea? The class is
org.apache.harmony.security.x501.AttributeTypeAndValueComparator.
Thanks,
Sian
--
Sian January
IBM Java Technology Centre, UK
Re: Re: [classlib] [security] equals method that just returns false
Posted by Alex Blewitt <al...@gmail.com>.
Not that it really makes any difference because you can't state that
the comparators are equivalent easily :-)
But it might make sense to get rid of that method, so that at least it
returns true if if the instances are the same. But all instances of
the same class should be the same, right? Maybe it would make sense to
have return 'other != null && this.getClass() == other.getClass()'.
(Unless there's some sort of sort parameter in the constructor... in
which case the default Object method would make sense).
So, whilst you may not be able to find other instances that are true,
it should at least return true for itself ...
Alex.
On 13/01/07, Nathan Beyer <nd...@apache.org> wrote:
> Assuming the class is actually a Comparator, that's probably fine,
> though it does seem a little weird. A Comparator is supposed to
> implement an equals method to determine if two Comparators are logical
> equal such that given two different instances they would both sort
> something exactly the same way. Perhaps this class is just saying that
> can never be possible.
>
> -Nathan
>
> On 1/12/07, Sian January <si...@googlemail.com> wrote:
> > Hello,
> >
> > I have found a class in the security module that overrides the equals
> > methods, but just returns false within that method. There doesn't seem to
> > be any comment about why it does this so I was just wondering if anyone had
> > any idea? The class is
> > org.apache.harmony.security.x501.AttributeTypeAndValueComparator.
> >
> > Thanks,
> >
> > Sian
> >
> > --
> > Sian January
> >
> > IBM Java Technology Centre, UK
> >
> >
>
Re: [classlib] [security] equals method that just returns false
Posted by Sian January <si...@googlemail.com>.
Thanks everyone - it looks like removing it would be the best option. I am
working on a FindBugs patch for the security module at the moment, so I will
include this fix in that patch unless anyone has any objections.
Sian
On 15/01/07, Stepan Mishura <st...@gmail.com> wrote:
>
> On 1/13/07, Nathan Beyer wrote:
> >
> > Assuming the class is actually a Comparator, that's probably fine,
> > though it does seem a little weird. A Comparator is supposed to
> > implement an equals method to determine if two Comparators are logical
> > equal such that given two different instances they would both sort
> > something exactly the same way. Perhaps this class is just saying that
> > can never be possible.
>
>
> Yes, it looks like a sub that implies that the class's instances
> shouldn't be compared. I'd remove it to inherit the method implementation
> from Object class.
>
> Thanks,
> Stepan.
>
> -Nathan
> >
> > On 1/12/07, Sian January <si...@googlemail.com> wrote:
> > > Hello,
> > >
> > > I have found a class in the security module that overrides the equals
> > > methods, but just returns false within that method. There doesn't
> seem
> > to
> > > be any comment about why it does this so I was just wondering if
> anyone
> > had
> > > any idea? The class is
> > > org.apache.harmony.security.x501.AttributeTypeAndValueComparator.
> > >
> > > Thanks,
> > >
> > > Sian
> > >
> > > --
> > > Sian January
> > >
> > > IBM Java Technology Centre, UK
> > >
> > >
> >
>
>
>
> --
> Stepan Mishura
> Intel Enterprise Solutions Software Division
>
>
--
Sian January
IBM Java Technology Centre, UK
Re: [classlib] [security] equals method that just returns false
Posted by Stepan Mishura <st...@gmail.com>.
On 1/13/07, Nathan Beyer wrote:
>
> Assuming the class is actually a Comparator, that's probably fine,
> though it does seem a little weird. A Comparator is supposed to
> implement an equals method to determine if two Comparators are logical
> equal such that given two different instances they would both sort
> something exactly the same way. Perhaps this class is just saying that
> can never be possible.
Yes, it looks like a sub that implies that the class's instances
shouldn't be compared. I'd remove it to inherit the method implementation
from Object class.
Thanks,
Stepan.
-Nathan
>
> On 1/12/07, Sian January <si...@googlemail.com> wrote:
> > Hello,
> >
> > I have found a class in the security module that overrides the equals
> > methods, but just returns false within that method. There doesn't seem
> to
> > be any comment about why it does this so I was just wondering if anyone
> had
> > any idea? The class is
> > org.apache.harmony.security.x501.AttributeTypeAndValueComparator.
> >
> > Thanks,
> >
> > Sian
> >
> > --
> > Sian January
> >
> > IBM Java Technology Centre, UK
> >
> >
>
--
Stepan Mishura
Intel Enterprise Solutions Software Division
Re: [classlib] [security] equals method that just returns false
Posted by Nathan Beyer <nd...@apache.org>.
Assuming the class is actually a Comparator, that's probably fine,
though it does seem a little weird. A Comparator is supposed to
implement an equals method to determine if two Comparators are logical
equal such that given two different instances they would both sort
something exactly the same way. Perhaps this class is just saying that
can never be possible.
-Nathan
On 1/12/07, Sian January <si...@googlemail.com> wrote:
> Hello,
>
> I have found a class in the security module that overrides the equals
> methods, but just returns false within that method. There doesn't seem to
> be any comment about why it does this so I was just wondering if anyone had
> any idea? The class is
> org.apache.harmony.security.x501.AttributeTypeAndValueComparator.
>
> Thanks,
>
> Sian
>
> --
> Sian January
>
> IBM Java Technology Centre, UK
>
>