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

SwitchBootstraps.enumSwitch() args not checked as documented.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • 26
    • 21, 25, 26
    • tools
    • None

      NPE is expected but not thrown when the invocationName is null:
      SwitchBootstraps.enumSwitch(
                      MethodHandles.lookup(),
                      null,
                      MethodType.methodType(int.class, FooEnum.class, int.class),
                      "FOO", "BAR", "BAZ");

      Label takes entries that are not in names of enum constants:
              // enum FooEnum {FOO, BAR, BAZ, BING}
              CallSite callSite = SwitchBootstraps.enumSwitch(
                      MethodHandles.lookup(),
                      "_",
                      MethodType.methodType(int.class, FooEnum.class, int.class),
                      "A", "B");

      Null string in label throws an IllegalArgumentException but not documented:
              // enum FooEnum {FOO, BAR, BAZ, BING}
              CallSite callSite = SwitchBootstraps.enumSwitch(
                      MethodHandles.lookup(),
                      "_",
                      MethodType.methodType(int.class, FooEnum.class, int.class),
                      "");

            jlahoda Jan Lahoda
            pchinnasamy Prabushankar Chinnasamy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: