to cache boxed values in the range -128 to 127. The following test case
for this property fails, showing that we don't cache.
class CacheBox {
public static void main(String[] args) {
Integer i1 = 12;
Integer i2 = 12;
if (i1 != i2) throw new Error();
}
}
- duplicates
-
JDK-4993091 Performance improvements questionable with new static valueOf() methods
-
- Closed
-
- relates to
-
JDK-6628737 Specification of wrapper class valueOf static factories should require caching of boxing range
-
- Resolved
-
-
JDK-8200478 For boxing conversion javac uses Long.valueOf which does not guarantee caching according to its javadoc
-
- Closed
-
-
JDK-5005319 wrapper objects created in wrapper classes are not cached
-
- Closed
-
-
JDK-5006128 Incorrect javadoc markup in Integer class description
-
- Closed
-
-
JDK-7040854 Different Integer objects created for the same primitive int value
-
- Closed
-
-
JDK-4931256 Boxed primitive types should cache common values
-
- Closed
-
-
JDK-6352381 Allow primitives to be used as 'first-class' Objects
-
- Closed
-
-
JDK-7190924 5.1.7: JLS does not mention caching of autoboxed longs
-
- Closed
-
-
JDK-8252827 Caching Integer.toString just like Integer.valueOf
-
- Closed
-