hg: jdk7/tl/langtools: 6979683: inconsistent interaction of reference cast with box/unbox conversions leaves out a useful case
maurizio.cimadamore at oracle.com
Thu Sep 2 13:29:09 PDT 2010
On 02/09/2010 20:30, Ulf Zibis wrote:
> Am 02.09.2010 20:50, schrieb Rémi Forax:
>> Le 02/09/2010 20:21, Ulf Zibis a écrit :
>>> is Bug ID: 6775385 NPE caused by ConditionalExpression and
>>> auto-boxing failure
>>> concerned by this bug ?
>> I don't think so, section 15.25 of JLS3 is clear.
>> For a conditional ?:, if one parameter is a primitive and the other
>> is a wrapper
>> of a numeric type, the wrapper must be unboxed.
> I think, it's worth to change the spec here.
An advantage of the current rules is that they somehow limit the
propagation of NPE related to unboxing e.g.
Integer i1 = null;
Integer i2 = true ? i : 2 //now NPE
... //possibly after several lines of code and further assignments
int i3 = i2; //with proposed change NPE would be here
More information about the compiler-dev