JDK 11 RFR of 8200478: For boxing conversion javac uses Long.valueOf which does not guarantee caching according to its javadoc

joe darcy joe.darcy at oracle.com
Wed Apr 25 15:18:51 UTC 2018

Hi David,

On 4/25/2018 5:08 AM, David Holmes wrote:
> Hi Joe,
> On 25/04/2018 10:30 AM, joe darcy wrote:
>> Hello,
>> Please review the patch below to update the specification of 
>> Long.valueOf(long) to require caching on [-128, 127]. The JDK 
>> implementation of this functionality has always cached in that 
>> region, even though it is not required.
> Seems very explicit that there is no requirement for Long to do 
> caching. So why should that change? Or put another way what has 
> changed that invalidates that clearly stated position?

JLS 9 changed the requirements on autobox caching going from Java SE 8 to 9:




The Long.valueOf method is used to implement autoboxing and its caching 
spec wasn't updated accordingly at the time.



More information about the core-libs-dev mailing list