openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: svn commit: r557089 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/ openjpa-lib/src/main/ja
Date Mon, 30 Jul 2007 05:45:37 GMT
It would not surprise me that IBM JDK was internally "interning"  
Integer instances much like String instances are interned, to reduce  
the number of instances of Integer and thereby improve garbage  
collection and instance count.

But our code should not be using == instead of equals. The identity  
of an Integer should never be assumed. Best practice even if not  
mandated by the VM spec.

Craig

On Jul 29, 2007, at 10:35 PM, Marc Prud'hommeaux wrote:

>> The problem is that the IBM JDK seems to want to create (copy) new  
>> Integer
>> objects when used as keys to the HashMap.put(k,v) method.  Any  
>> other key
>> types are just used as is (no copy).  But, Integer types as keys  
>> are copied
>> into new Integer objects.
>>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message