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

Mike Duigou mike.duigou at oracle.com
Mon Sep 16 22:49:43 UTC 2013


Ping!

(still need a reviewer on this)

Mike

On Sep 4 2013, at 11:44 , Mike Duigou wrote:

> Hello all;
> 
> I have updated the proposed changeset for this issue. I have moved the note to the interface documentation for Collection and Map and made it more general:
> 
>> Some collection operations which perform recursive traversal of the
>> collection may fail with an exception for self-referential instances where
>> the collection directly or indirectly contains itself. This includes the
>> {@code clone()}, {@code equals()}, {@code hashCode()} and {@code toString()}
>> methods. Implementations may optionally handle the self-referential scenario,
>> however most current implementations do not do so.
> 
> The webrev is at:
> 
> http://cr.openjdk.java.net/~mduigou/JDK-7057785/1/webrev/
> 
> Mike
> 
> On Aug 27 2013, at 19:06 , Mike Duigou wrote:
> 
>> 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.
>> 
>> 
>> http://cr.openjdk.java.net/~mduigou/JDK-7057785/0/webrev/
>> 
>> Cheers,
>> 
>> Mike
> 




More information about the core-libs-dev mailing list