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

NullPointerException not reported

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 18
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b14

      Description

      As reported here:
      https://mail.openjdk.java.net/pipermail/compiler-dev/2021-August/017768.html

      A NPE should be reported for:
      ---
      public void foo(Object o) {
              switch (o) {
                default: break;
                case String s :System.out.println(s); break;
              }
      }
      public static void main(String[] args) {
              (new X()).foo(null); // NPE expected, but prints null
      }
      ---

      but it is not.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlahoda Jan Lahoda
              Reporter:
              jlahoda Jan Lahoda
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: