hg: jdk7/tl/langtools: 6979683: inconsistent interaction of reference cast with box/unbox conversions leaves out a useful case
Ulf Zibis
Ulf.Zibis at gmx.de
Thu Sep 2 16:29:25 PDT 2010
Am 02.09.2010 22:29, schrieb maurizio cimadamore:
> 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 :
>>>> Hi,
>>>>
>>>> is Bug ID: 6775385 NPE caused by ConditionalExpression and auto-boxing failure
>>>> <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6775385>
>>>> concerned by this bug ?
>>>>
>>>> -Ulf
>>>
>>> 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
>
This would imply, that an Integer variable is never allowed to be null. ?
If it's in the intention of the programmer to allow i2 to be null, IMHO it's correct to have the NPE
on int i3 = i2;
Do I have missed something?
-Ulf
More information about the compiler-dev
mailing list