Must autoboxing call valueOf?
Sam Munkes
sam.munkes at gmail.com
Thu Aug 6 00:28:11 UTC 2015
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/5115e20f/attachment.html>
More information about the compiler-dev
mailing list