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

Roger Riggs rriggs at openjdk.java.net
Tue Oct 13 19:52:23 UTC 2020


On Tue, 13 Oct 2020 19:40:06 GMT, Dan Smith <dlsmith at openjdk.org> wrote:

>> Yes, the compatibility concern is foremost. We don't intend to change the behavior (yet) so the exact language used to
>> describe what is being changed is important.  A simple assertion that Integer is ValueBased breaks compatibility. The
>> JLS requirement for reference equality for small values is at odds with ValueBased.
>
> 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.

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

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



More information about the valhalla-dev mailing list