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:41:56 PDT 2010


  Am 02.09.2010 23:03, schrieb Rémi Forax:
> 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 :
>>>>> 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
>>
>> Maurizio
>>>
>>> -Ulf
>
> Ulf,
> 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.
>

Rémi,
thanks.
I guess you have some use scenarios in mind. Can you share one to better understand your opinion?

-Ulf





More information about the compiler-dev mailing list