_Jv_HashCode
Per Bothner
per@bothner.com
Tue May 9 18:19:00 GMT 2000
Tom Tromey <tromey@cygnus.com> writes:
> I wonder if this should be `(jint) obj >> 2' instead.
> That would put more information in the low bits.
Seems plausible. However, it will cause gdb lossage.
We defined gdb so that when the language is Java, gdb prints out
for an object reference:
CLASSNAME@HEXADDRESS
in the same way that when the language is C++ gdb prints out:
(CLASSNAME *) 0xHEXADDRESS
The rationale for this syntax is the the default toString() method
defined as:
OBJ.getClass().getName() + '@' + Integer.toHexString(OBJ.hashCode())
What gdb actually prints out is:
OBJ.getClass().getName() + '@'
+ Integer.toHexString(System.identityHashCode(OBJ))
If you change _Jv_Hash so that System.identityHashCode(OBJ) is
no longer equals to (jint)(OBJ) then the gdb output syntax
probably no longer makes sense.
> This matters in some situations. For instance, the interned string
> hash table has a size that is a power of 2. In this case 3/4 of the
> entries in this table will only be used when there are collisions.
But the interned string hash table isn't using _Jv_Hash I trust?
It is presumably hashing on the *contents* of the string, not its
location.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/
More information about the Java
mailing list