Details
Description
ReuseFactory has a cache of Byte, Short, Integer and Long instances to avoid excessive allocation of such instances.
As of Java 5, the JVM has a cache of its own, available through static valueOf() methods in these classes.
The JVM's cache is guaranteed to have at least all values in the range [-128, 127]. ReuseFactory currently caches Integer instances in the range [-1, 18] plus a few special values, and Byte, Short and Long instances in the range [0, 10].
If we change ReuseFactory so that it uses the JVM's cache, the number of cache misses will be lower, and the code will become shorter.