Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8267503

[lworld] [lw3] NPE message thrown by checkcast is incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • None
    • repo-valhalla
    • hotspot
    •  

       

      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



            fparain Frederic Parain
            fparain Frederic Parain
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: