Hi!
As for caching integers, Integer.valueOf(int) does caching. At least in Sun's
JDK 5:
/**
* Returns a <tt>Integer</tt> instance representing the specified
* <tt>int</tt> value.
* If a new <tt>Integer</tt> instance is not required, this method
* should generally be used in preference to the constructor
* {...@link #Integer(int)}, as this method is likely to yield
* significantly better space and time performance by caching
* frequently requested values.
*
* @param i an <code>int</code> value.
* @return a <tt>Integer</tt> instance representing <tt>i</tt>.
* @since 1.5
*/
public static Integer valueOf(int i) {
final int offset = 128;
if (i >= -128 && i <= 127) { // must cache
return IntegerCache.cache[i + offset];
}
return new Integer(i);
}
Greetings,
Milosz
>
> Hi,
> A previous discussion [3] led to the conclusion that OpenJPA should
> continue supporting JDK5 runtime. But OpenJPA libraries itself are compiled
> with JDK6 compiler. Certain parts of JPA 2.0 specification is making it
> mandatory that JPA applications compile and run only in JDK6 -- and we are
> trying to make those parts of the specification optional to retain the
> ability to support JDK5 runtime.
>
> The major issue to move to JDK6 was supporting JDBC4 (refer OPENJPA-5 [1]).
> Also, readability can be improved and a degree of type-safety can be
> achieved by more widespread usage of generics throughout the core OpenJPA
> codebase [2]. Some of the suggestions in your post has been addressed in
> [2].
>
> Please note that Numbers.valueOf() caches. Not exactly same as
> Integer.valueOf().
> In any case, smaller commits/patches are preferred to the larger ones.
>
>
> [1] http://issues.apache.org/jira/browse/OPENJPA-5
> [2] http://issues.apache.org/jira/browse/OPENJPA-1050
> [3]
> http://n2.nabble.com/-DISCUSS--Drop-build-support-for-Java-5--tc2539470.html#a2545464
>
>
>
> -----
> Pinaki Poddar http://ppoddar.blogspot.com/
>
> http://www.linkedin.com/in/pinakipoddar
> OpenJPA PMC Member/Committer
> JPA Expert Group Member
> --
> View this message in context:
> http://n2.nabble.com/small-increments-tp3019067p3019630.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>
>