RFR: 7057785 : (xs) Add note to hashCode() that support for self referential is optional

Mike Duigou mike.duigou at oracle.com
Wed Aug 28 02:06:26 UTC 2013

Hello all;

Fairly frequently it is reported that various Collection/Map implementations of hashCode() fail when the instance directly or indirectly contains itself. For a variety of reasons, mostly performance and resource related, most implementations choose not to support calculation of hash codes for self-referential collections. This is not likely to change. So to reduce confusion and "bug" reports I am proposing a non-normative @apiNote be added to Collection and HashMap. The text of the proposed note is:

> Support for calculation of hash code by self referential {Collection|Map}s (they either directly or indirectly contain themselves) is optional. Few Collection implementations support calculation of hash code for self referential instances.




More information about the core-libs-dev mailing list