JDK-6239319 : Configurable cache for valueOf method in the Short, Integer and Long classes
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2005-03-11
  • Updated: 2011-02-16
  • Resolved: 2009-10-09
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
This RFE requests users should be able to configure the range of cached values used by the Short.valueOf(short), Integer.valueOf(int) and Long.valueOf(long), including the ability to turn off caching. This would be achieved by the user passing a set of system properties to the JVM when it is started, e.g. :

> java -Djava.lang.Integer.cache=-521..1024 MyApplication

These settings should only be taken as strong hints for tuning purposes and applications should not rely on the fact that specifc values are either cached or not in order to function correctly. Thus if an application requires caching it should implement its own secondary cache. This clause would liberate future releases from the burden of supporting these settings for backward compatability.

JUSTIFICATION :
The current cached range of values for these methods is -128 to 127. While this standard range provides a performance enhancement for most applications, many applications also make heavy use of values outside of this range thus would benefit if they could tune the cache range to their needs.  This would go hand in hand with the other currently available JVM parameters used to configure time / space tradeoffs.

The ability to turn off caching would also allow for the setting of a baseline benchmark to compare different settings when tuning an application.
###@###.### 2005-03-11 08:52:23 GMT

Comments
EVALUATION Closing as duplicate of 6807702.
09-10-2009

EVALUATION The caching in the range of -128 to 127 is mandated by the current version of the language specification and cannot be disabled while remaining compliant. Before evaluating whether or not a user configurable cache would be worthwhile to support, it would be essential to have particular representative applications that could be measurably improved or hurt by diffenent caching policies. ###@###.### 2005-03-11 22:15:19 GMT
11-03-2005