equals, hash code and comapreTo and others

Posts regarding potential bugs, enhancement requests, and general feedback on use of dyn4j
alpedar
Posts: 7
Joined: Sat Jan 25, 2014 11:08 am

equals, hash code and comapreTo and others

Postby alpedar » Sat Feb 01, 2014 8:30 am

When peeking into source code, I noticed that Vector2 does not have its hashCode even though it has equals.
Then I realized that it has equals(Vector), not equals(Object), so it is imo not strictly contract of equals-hashCode breach, but it is imo dangerous.

I ran FindBugs on sources and found multiple similar problems.
Here is findbugs result
https://drive.google.com/file/d/0B5mUAT ... sp=sharing

William
Site Admin
Posts: 349
Joined: Sat Feb 06, 2010 10:23 pm

Re: equals, hash code and comapreTo and others

Postby William » Sat Feb 01, 2014 12:43 pm

Thanks for the report. I'll take a look at some of these. After a brief scan, most are by design, but I can see a few places for improvement.

William

zoom
Posts: 143
Joined: Sun Mar 17, 2013 3:57 pm
Location: Stockholm, Sweden
Contact:

Re: equals, hash code and comapreTo and others

Postby zoom » Sun Feb 02, 2014 8:12 am

It sure can be confusing. It's easy to peek at the javadoc and think that the ordinary equals is implemented when in fact it isn't. But then again, what should you call that method? "hasSameValues" or "meansTheSameLocation" doesn't sound so good. Personally, I'm can't decide if I think they should be renamed or not :-)


Return to “Bugs, Enhancements, Feedback”

Who is online

Users browsing this forum: No registered users and 1 guest