logo       

Re: Are there any annotations to help find invalid hashCode() and equals() : msg#00042

java.findbugs.general

Subject: Re: Are there any annotations to help find invalid hashCode() and equals() methods?

I'm not aware of any such annotations, but it sounds like a good idea.

I wonder if you could generalize the annotations a bit to say that particular
fields should or should not be mentioned in certain methods:

private @MustUseIn("hashCode,equals") String foo;

private @MustNotUseIn("hashCode,equals") int bar;

-Dave

On 10/13/06, Rob Oxspring <roxspring@xxxxxxxxxxxx> wrote:
Hi,

In my object model I have some fields that should always be referred to
in equals() and hashCode() implementations and some that should never be
referred to. It would be really helpful I could annotate these facts so
that FindBugs can spot any mistakes as I or my team mates change fields
without modifying equals()/hashCode() or vice versa. Assuming the
annotations were standard or standardised then Eclipse (or whatever IDE)
could even be taught to respect the annotations when generating the
equals() and hashCode() implementations.

Anybody heard of such annotations? or have an idea where else I should
suggest the idea?

Cheers,

Rob
_______________________________________________
Findbugs-discuss mailing list
Findbugs-discuss@xxxxxxxxxxxxxxxxxx
http://mailman.cs.umd.edu/mailman/listinfo/findbugs-discuss



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise