One new behavior of the checkcast bytecode in Valhalla is to throw a NullPointerException whenever there's an attempt to cast the null reference to a null-free type. However, the error message generated for this exception is incorrect, suggesting that no such NPE should be thrown:
java.lang.NullPointerException: There cannot be a NullPointerException at bci 23 of method void NPECheckcastTest.main(java.lang.String[])
By comparison, here's the error message of an NPE when getfield encounter a null receiver:
java.lang.NullPointerException: Cannot read field "x" because "<local1>" is null
java.lang.NullPointerException: There cannot be a NullPointerException at bci 23 of method void NPECheckcastTest.main(java.lang.String[])
By comparison, here's the error message of an NPE when getfield encounter a null receiver:
java.lang.NullPointerException: Cannot read field "x" because "<local1>" is null