SwitchBoostraps.typeSwitch does not throw IAE as expected

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P3
    • None
    • Affects Version/s: 25, 26, 27
    • Component/s: tools
    • None

      The document states that SwitchBoostraps.typeSwitch() throws
      IllegalArgumentException - if the invocation type is not a method type of first parameter of a reference type, second parameter of type int and with int as its return type

      In the following case, when the first param is not a ref type, IAE is expected but not thrown.
              SwitchBootstraps.typeSwitch(
                      LOOKUP,
                      DUMMY_INVOCATION_NAME,
                      MethodType.methodType(
                              int.class, int.class, int.class // <- First param is int.class and not a reference type.
                      ),
                      LABELS);

      Also, the following exception is not thrown:
          IllegalArgumentException - if labels contains an element that is not of type Boolean when target is a Boolean.class

              var labels = new Object[]{5, 10};
              CallSite callSite = SwitchBootstraps.typeSwitch(
                      LOOKUP,
                      DUMMY_INVOCATION_NAME,
                      MethodType.methodType(
                              int.class, Boolean.class, int.class
                      ),
                      labels
              );
              callSite.getTarget().invoke(true, 0);

            Assignee:
            Angelos Bimpoudis
            Reporter:
            Prabushankar Chinnasamy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: