Bug 118877 - Programming Guide incorrect about hashCode requirements
Summary: Programming Guide incorrect about hashCode requirements
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Docs (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 1.5.0RC1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-01 12:19 EST by Chris Long CLA
Modified: 2005-12-07 12:11 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Long CLA 2005-12-01 12:19:33 EST
This is a minor point, but on the "Basic Techniques" page in the Programming Guide
(http://www.eclipse.org/aspectj/doc/released/progguide/examples-basic.html), in the section "The HashablePoint aspect", it says

"Different implementations [of hashCode] are allowed [to] return different integers, but must return distinct integers for distinct objects, and the same integer for objects that test equal."

It is not true that hashCode must return distinct integers for distinct objects. It's preferable, since it makes the hashCode more useful (and may speed up hashtables, etc.), but it's not required. From the javadocs on Object.hashCode:

"It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables."

BTW, I didn't specify a version because I couldn't find a version number in the document.
Comment 1 Adrian Colyer CLA 2005-12-06 08:15:23 EST
we should tidy this up in the docs for 1.5.0...
Comment 2 Andrew Clement CLA 2005-12-07 12:11:02 EST
i've updated the doc to address this, it no longer incorrectly states the hashCode() must be different for non-equal objects.