Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / February 2004

Tip: Looking for answers? Try searching our database.

how long is the unicity (if any)of the System.identityHashCode()?

Thread view: 
NOBODY - 02 Feb 2004 03:27 GMT
How long lasts the unicity (if any) of the System.identityHashCode()?

I created code that keep track of seen identityhashcodes for instances
created and unreferenced in a loop.

**** I was surprised to see that these identityhashcode can be reused! ****

The language spec says noting about the unicity of those (at any given
time) and especially not for periods of tiem.

Spec menyions that most jvm would use the heap address (which would explain
why these identityhashcode could be reused)

**** The question is:

At what time is an identityhashcode invalidated and reusable?
If I have a finalize() method, at which time the object is considered
unreferenced, could its identityhashcode be reused while the finalize() is
running?

My problem is that I associated data to an object, in an external
diskcache, by a key whose value is the identityhashcode, (trying to make
the key unique), and I must garbage collect it.
Christophe Vanfleteren - 02 Feb 2004 09:09 GMT
> How long lasts the unicity (if any) of the System.identityHashCode()?
>
[quoted text clipped - 20 lines]
> diskcache, by a key whose value is the identityhashcode, (trying to make
> the key unique), and I must garbage collect it.

Don't do that. A hashcode is never guaranteed to be unique. You'll just have
to generate your own PK's.

Signature

Kind regards,
Christophe Vanfleteren



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.