Java Code Examples for sun.invoke.util.ValueConversions#varargsArray()

The following examples show how to use sun.invoke.util.ValueConversions#varargsArray() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ValueConversionsTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testVarargsArray() throws Throwable {
    //System.out.println("varargsArray");
    final int MIN = START_ARITY;
    final int MAX = MAX_ARITY-2;  // 253+1 would cause parameter overflow with 'this' added
    for (int nargs = MIN; nargs <= MAX; nargs = nextArgCount(nargs, 17, MAX)) {
        MethodHandle target = ValueConversions.varargsArray(nargs);
        Object[] args = new Object[nargs];
        for (int i = 0; i < nargs; i++)
            args[i] = "#"+i;
        Object res = target.invokeWithArguments(args);
        assertArrayEquals(args, (Object[])res);
    }
}
 
Example 2
Source File: ValueConversionsTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testVarargsArray() throws Throwable {
    //System.out.println("varargsArray");
    final int MIN = START_ARITY;
    final int MAX = MAX_ARITY-2;  // 253+1 would cause parameter overflow with 'this' added
    for (int nargs = MIN; nargs <= MAX; nargs = nextArgCount(nargs, 17, MAX)) {
        MethodHandle target = ValueConversions.varargsArray(nargs);
        Object[] args = new Object[nargs];
        for (int i = 0; i < nargs; i++)
            args[i] = "#"+i;
        Object res = target.invokeWithArguments(args);
        assertArrayEquals(args, (Object[])res);
    }
}