RFR 8138840: NPE when compiling bitwise operations with illegal operand types

ShinyaYoshida bitterfoxc at gmail.com
Mon Oct 5 00:42:21 UTC 2015


Hi Jan, Maurizio and compiler group,
I found the NPE bug related to
http://hg.openjdk.java.net/jdk9/dev/langtools/rev/098657cc98c9
It's for bitwise operations with illegal operand types:

int n = 0;
double d = 0;
System.out.println(n & d);

I've just filed this issue:

https://bugs.openjdk.java.net/browse/JDK-8138840

And I already have the fix for this.
Could you review my patch?

http://cr.openjdk.java.net/~shinyafox/8138840/webrev.00/

Now, BinaryNumericOperator is used for bitwise operators in Operators.
BinaryNumericOperator accepts numeric operand types but bitwise operators
should be allowed for integral types(JLS 15.22.1).
So the accepted types are same as shift operators'(BinaryShiftOperator).

In my change, I create BinaryBitwiseOperator which allows only the integral
types such as BinaryShiftOperator I use it for bitwise operators instead of
BinaryNumericOperator.
(And I also change the comment for BinaryBooleanOperator, because it is not
"bitwise operator(JLS 15.22.1)" but "logical operator(15.22.2).")

Regards,
shinyafox


More information about the jdk9-dev mailing list