hg: jdk7/tl/langtools: 6979683: inconsistent interaction of reference cast with box/unbox conversions leaves out a useful case
forax at univ-mlv.fr
Thu Sep 2 14:03:26 PDT 2010
Le 02/09/2010 22:29, maurizio cimadamore a écrit :
> 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
I agree with you that the rules for conditional are surprising,
but if you change that part of the spec, you will break a lot of code.
More information about the compiler-dev