Community
Participate
Working Groups
Build ID: M20060921-0945 Steps To Reproduce: Compile and run this code: package test; public class Test { public static void main(String[] args){ Boolean myBool = null; if (myBool){ }}} This should throw a NullPointerException - in 14.9.1 of the JLS the execution of an if statement is defined to evaluate its test expression. When myBool is evaluated, it should dereference the null value and so throw an NPE. Interestingly, if you replace "if (myBool) { }" with "if (myBool);" the code does throw an NPE.
In case there is an unboxing conversion involved, the condition needs to be generated and popped from the stack. Philippe, I'll prepare a patch for single name reference, field reference, qualified name reference and array reference.
Created attachment 59477 [details] Regression tests
Created attachment 59482 [details] Proposed fix
Released for 3.3M6.
Verified for 3.3 M6 using build I20070320-0010.