RFR: 8254275: Development to revise "value-based class" & apply to wrappers

Dan Smith dlsmith at openjdk.java.net
Tue Oct 13 19:52:23 UTC 2020


On Tue, 13 Oct 2020 19:47:44 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> To clarify my thinking on the identity/cacheing behavior of wrappers:
>> 
>> - Integer should claim to be a value-based class. I've made that part of this issue, and will include it in another
>>   iteration of the code.
>> 
>> - ValueBased.html needs to allow for factory methods that guarantee consistent identity for at least some results. It's
>>   okay to relax the definition of "value-based class" in this way—it doesn't change the contract of other value-based
>>   classes' factories, just gives them the option to do cacheing if they want.
>> 
>> - When Integer becomes a primitive class, the consistent identity guarantee of `Integer.valueOf` will continue to be
>>   true, and will extend to the full domain of Integers.
>
> Byte, Short, Integer, and Long all have caches for small values.

Yes, understood. I was using Integer as an example, but the above should apply to all of those classes.

-------------

PR: https://git.openjdk.java.net/valhalla/pull/222



More information about the valhalla-dev mailing list