MethodHandles.foldArguments handle negative pos

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: core-libs

      A DESCRIPTION OF THE PROBLEM :
      MethodHandles.foldArguments(MethodHandle, Int, MethodHandle) needs 0 based index pos.
      But negative pos triggers ArrayIndexOutOfBoundsException, rather than IAE.

      import java.lang.invoke.MethodHandle;
      import java.lang.invoke.MethodHandles;
      import java.lang.invoke.MethodType;
      import org.testng.annotations.*;

      public class FoldTest {


          @Test(expectedExceptions = IllegalArgumentException.class)
          public void testNegativePosition() throws Throwable {
              MethodHandle target = MethodHandles.lookup().findStatic(FoldTest.class, "target",
                      MethodType.methodType(int.class, int.class, int.class));
              MethodHandle combiner = MethodHandles.lookup().findStatic(FoldTest.class, "combiner",
                      MethodType.methodType(int.class, int.class));
              
              MethodHandles.foldArguments(target, -1, combiner);
          }

          private static int target(int x, int y) { return 0; }
          private static int combiner(int x) { return 0; }
      }


            Assignee:
            Unassigned
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: