commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [LANG] - suggestions for new Identity Hash code classes
Date Tue, 16 Sep 2008 12:44:14 GMT
sebb schrieb:
> I think I've found a fix to LANG-459 - which is to borrow some code
> from Apache Axis.
> The required code is a single short class - IDKey (e.g.
> It could be added as a private class of HashCodeBuilder, but it has
> wider use, so should probably be added as a public class.
Seems reasonable to me.  It does look like it will solve LANG-459. And 
as you say, this problem may be reasonably common.

What about making the IDKey class final? One thing that does concern me 
is that HashSet lookup using an Integer object as the key should be 
pretty fast. Using an IDKey object as the key may not perform as well. 
Making IDKey final would at least help. And I cannot see any reason why 
someone would want to subclass IDKey.

One other concern is regarding garbage collection. From a brief look at 
the code, this thread-local registry object contains a set of Integer 
hashcodes. With this change, the set will now contain real hard 
references to objects, preventing them from being garbage-collected 
while they are in the set. Does this matter?
> Seems to me it would also be useful to add IdentityHashMap and
> IdentityHashSet classes as well, given that LANG still targets Java
> 1.3.
> And do these classes need a new package, or would the top-level package be OK?

No opinion.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message