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

NullPointerException not reported

XMLWordPrintable

    • b14

        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.

              jlahoda Jan Lahoda
              jlahoda Jan Lahoda
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: