On Mon, 3 Jul 2000, Christopher Smith wrote:
> > I don't get it. That was the whole point of adding the
> > System.identityHashCode() method to 1.1. It was designed
> > to return a UID in the case that a class overloaded
> > the hashCode() method. Now folks seem to be saying "oh,
> > yeah that was changed for 1.2". Changed to what?
> > How would you suggest I generate a UID for two
> > different object of the same class that return
> > the exact same hash code? I can't get the memory
> > location to implement my own UID method.
>
> Nope, the whole point of System.identityHashCode() was added so that == had
> equivalent operators to Object.equals(Object). Essentially it allowed you to
> create an identity hash table. If they had ment it to be a uid they would
> have called it Object.getUid(). ;-)
Humm, I am not sure if we are saying the same thing with different words.
The System.identityHashCode() is not the equivalent of == in JDK 1.2. In
JDK 1.1 it worked that way but now I am not sure what it is the
equivalent of. It is most certainly not the .equals() method, the
error example I posted showed that the two objects that mapped
to the same hash would return false from a equals() comparison.
My example also shows that identityHashCode() is not the equivalent of ==,
the == test for two objects that hash to the same value returned false.
What exactly do you mean when you say "identity hash table"? What
would such a table do for you?
> They didn't change the API. The docs have been the same for quite some time.
> They did fix a conflict in the spec that said the following:
Yes they did. The API does not work the same way it did in JDK 1.1.
> Standard hashtables are based on Object.equals() and as such deal with the
> hashCode collision issue. So, if you just use a standard Hashtable (or Set
> depending on your needs), make sure you're using identityHashCode() and
> =='s, then collisions will be dealt with for you.
I am using a "standard hashtable". I need to map a UID string to a
single Object, without a UID provided by the identityHashCode(),
I am going to have a hard time doing that.
Mo DeJong
Red Hat Inc
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]