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

enum switch on null fails to throw NullPointerException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.0
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b46
    • CPU:
      generic
    • OS:
      solaris_8

      Description

      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");
              }
          }
      }

        Attachments

          Activity

            People

            Assignee:
            gafter Neal Gafter
            Reporter:
            gafter Neal Gafter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: