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

enum switch on null fails to throw NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 5.0
    • tools
    • b46
    • generic
    • solaris_8

      This test case fails under the current implementation of enums:

      enum EnumSw {
          foo, bar, baz;

          public static void main(String[] args) {
              EnumSw e = null;
              try {
                  switch (e) {
                  default: break;
                  }
                  throw new Error("failed to throw NullPointerException");
              } catch (NullPointerException ex) {
                  System.out.println("passed");
              }
          }
      }

            gafter Neal Gafter (Inactive)
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: