>
> Please consider adding (the default) Object.hashCode()
> and System.identityHashCode() to the short list of
> things that seems immutable to all threads, even in
> case of data race:
> 1. it is the "identity" of the object.
> 2. without it, java.util.IdentityHashMap can be
> broken.
> 3. it is the last Object() method to protect.
>
>From the hashCode contract:
Whenever it is invoked on the same object more than once during an execution
of a Java application, the hashCode method must consistently return the same
integer, provided no information used in equals comparisons on the object is
modified.
The only way Object.hashCode() could be implemented legally so as not to be
immutable is if you detect that a change has been made to the the object
that can affect equals comparisons. This would be tough, as the equals
comparison for Object is based on reference identity.
Jeremy
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:05 EDT