Must autoboxing call valueOf?
Jonathan Gibbons
jonathan.gibbons at oracle.com
Thu Aug 6 00:34:15 UTC 2015
Sam,
The relevant text would appear to be in JLS 5.1.7, Boxing Conversion.
https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.1.7
-- Jon
On 08/05/2015 05:28 PM, Sam Munkes wrote:
> Hi -
>
> A colleague of mine was wondering if the following statements are
> guaranteed to be true:
> ((Boolean)true) == Boolean.TRUE
> ((Boolean)true) == Boolean.valueOf(true)
> ((Integer)1) == Integer.valueOf(1)
>
> javac does indeed call valueOf() for autoboxing, but is this behavior
> mandated by the JLS?
>
> The answers on stackoverflow
> http://stackoverflow.com/questions/31445024/does-autoboxing-call-valueof agree
> that although in practice the compilers use valueOf(), the JLS does
> not mandate it.
>
> Does anyone here know more on the subject?
>
> Thanks
>
> Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20150805/2e950c60/attachment.html>
More information about the compiler-dev
mailing list