Re: Hashtables
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Tue, 13 Sep 2005 19:30:52 +0100
Kenneth Patrick Turvey wrote:
Whoops. I misread the source, not his comment. I looked a bit closer and with some digging I found this tidbit:
Look at the source? That's an idea.
This is the function that ends up returning the value used for Object.hashCode(). It looks like an address, but I'm not positive. A jobject could be something else I guess. I looked around in the source and was unable to find a definitive answer in a reasonable amount of time.
In the mustang source under the hotspot directory, grepping brings up lots of stuff. It seems as if the default algorithm is to use the address at the first attempt to read hashCode. There are other algorithms for returning a shared unsynchronised random number, a thread-local random number and 1.
The address is shifted to get the good bits. Experimentation points to the hash code always being positive (just). They'll be in trouble if it generates zero. I'd be tempted to always store the initial address >> 3, or change the header (and add a trailer) when hashCode is first used and first copy after use.
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- References:
- Hashtables
- From: JTMOBAP
- Re: Hashtables
- From: Thomas Hawtin
- Re: Hashtables
- From: JTMOBAP
- Re: Hashtables
- From: Patricia Shanahan
- Re: Hashtables
- From: JTMOBAP
- Re: Hashtables
- From: Kenneth Patrick Turvey
- Re: Hashtables
- From: Dale King
- Re: Hashtables
- From: Kenneth Patrick Turvey
- Re: Hashtables
- From: Roedy Green
- Re: Hashtables
- From: Kenneth Patrick Turvey
- Hashtables
- Prev by Date: Re: A bigger Window
- Next by Date: Re: Java ok on XP but not on W98: solved!
- Previous by thread: Re: Hashtables
- Next by thread: Re: Hashtables
- Index(es):
Relevant Pages
|