RFR:8187362:Nashorn unsigned right shift operator unexpectedly returns floating-point

Sundararajan Athijegannathan sundararajan.athijegannathan at oracle.com
Fri Sep 15 14:36:03 UTC 2017


Nope. It is as per the spec!

https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.25

/

Otherwise, binary numeric promotion (§5.6.2) is applied to the operand 
types, and the type of the conditional expression is the promoted type 
of the second and third operands.

Note that binary numeric promotion performs value set conversion 
(§5.1.13) and may perform unboxing conversion (§5.1.8).
/

-Sundar

On 15/09/17, 7:41 PM, Attila Szegedi wrote:
> Wow, that hidden unboxing and primitive widening in the conditional operator is sinister. I had to write a small test program and use javap on it to see it with my own eyes. Surely this isn’t a javac bug?
>
> Attila.
>
>> On 2017. Sep 13., at 11:18, Hannes Wallnöfer<hannes.wallnoefer at oracle.com>  wrote:
>>
>> +1
>>
>> Hannes
>>
>>> Am 13.09.2017 um 07:21 schrieb Sundararajan Athijegannathan<sundararajan.athijegannathan at oracle.com>:
>>>
>>> +1
>>>
>>> PS. You may want to add explanation to the bug (if not done already). We may have to revisit conditional expressions elsewhere as well....
>>>
>>> -Sundar
>>>
>>> On 13/09/17, 10:37 AM, Priya Lakshmi Muthuswamy wrote:
>>>> Updated patch : http://cr.openjdk.java.net/~pmuthuswamy/8187362/webrev.01/
>>>> corrected the alignment.
>>>>
>>>> Thanks,
>>>> Priya
>>>>
>>>> On 9/13/2017 9:58 AM, Priya Lakshmi Muthuswamy wrote:
>>>>> Hi,
>>>>>
>>>>> Please review JDK-8187362 : Nashorn unsigned right shift operator unexpectedly returns floating-point
>>>>> JBS: https://bugs.openjdk.java.net/browse/JDK-8187362
>>>>> webrev: http://cr.openjdk.java.net/~pmuthuswamy/8187362/webrev.00/
>>>>>
>>>>> Thanks,
>>>>> Priya


More information about the nashorn-dev mailing list