- 
    Enhancement 
- 
    Resolution: Unresolved
- 
     P4 P4
- 
    None
- 
    None
- 
        generic
- 
        generic
                    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; }
}
            
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; }
}
- caused by
- 
                    JDK-8139885 implement JEP 274: enhanced method handles -           
- Closed
 
-