Examples of invokeExact()


Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String.class, Object.class, Integer.class, Float.class)
                .convert(target.type().returnType(), target.type().parameterArray())
                .invoke(target);

        assertEquals(MethodType.methodType(String.class, Object.class, Integer.class, Float.class), handle.type());
        assertEquals(null, (String)handle.invokeExact((Object)"foo", (Integer)5, (Float)5.0f));
    }

    @Test
    public void testCast() throws Throwable {
        MethodHandle target = mixedHandle();
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String.class, Object.class, byte.class, int.class)
                .cast(target.type())
                .invoke(target);

        assertEquals(MethodType.methodType(String.class, Object.class, byte.class, int.class), handle.type());
        assertEquals(null, (String)handle.invokeExact((Object)"foo", (byte)5, 5));
    }

    @Test
    public void testCast2() throws Throwable {
        MethodHandle target = mixedHandle();
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String.class, Object.class, byte.class, int.class)
                .cast(target.type().returnType(), target.type().parameterArray())
                .invoke(target);

        assertEquals(MethodType.methodType(String.class, Object.class, byte.class, int.class), handle.type());
        assertEquals(null, (String)handle.invokeExact((Object)"foo", (byte)5, 5));
    }

    @Test
    public void testDropReorder() throws Throwable {
        MethodHandle target = Subjects.concatHandle();
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .drop(0, 2)
                .permute(0, 0)
                .invoke(target);

        assertEquals(MethodType.methodType(String.class, Integer.class, Float.class, String.class), handle.type());
        assertEquals("foofoo", (String)handle.invokeExact((Integer) 0, (Float) 0.0f, "foo"));
    }

    @Test
    public void testSpread() throws Throwable {
        MethodHandle target = Subjects.concatHandle();
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String.class, Object[].class)
                .spread(String.class, String.class)
                .invoke(target);
       
        assertEquals(MethodType.methodType(String.class, Object[].class), handle.type());
        assertEquals("foobar", (String)handle.invokeExact(new Object[] {"foo", "bar"}));
    }

    @Test
    public void testSpreadCount() throws Throwable {
        MethodHandle target = Subjects.concatHandle();
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String.class, String[].class)
                .spread(2)
                .invoke(target);
       
        assertEquals(MethodType.methodType(String.class, String[].class), handle.type());
        assertEquals("foobar", (String)handle.invokeExact(new String[] {"foo", "bar"}));
    }

    @Test
    public void testCollect() throws Throwable {
        MethodHandle handle = Binder
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String[].class, String.class, String.class, String.class)
                .collect(1, String[].class)
                .invokeStatic(LOOKUP, BinderTest.class, "varargs");

        assertEquals(MethodType.methodType(String[].class, String.class, String.class, String.class), handle.type());
        String[] ary = (String[])handle.invokeExact("one", "two", "three");
        assertEquals(2, ary.length);
        assertEquals("two", ary[0]);
        assertEquals("three", ary[1]);

        MethodHandle handle2 = Binder
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(Subjects.StringIntegerIntegerIntegerString.type())
                .collect(1, 3, Integer[].class)
                .invoke(Subjects.StringIntegersStringHandle);

        assertEquals(MethodType.methodType(String.class, String.class, Integer.class, Integer.class, Integer.class, String.class), handle2.type());
        assertEquals("[foo, [1, 2, 3], bar]", (String)handle2.invokeExact("foo", new Integer(1), new Integer(2), new Integer(3), "bar"));
    }

    @Test
    public void testVarargs() throws Throwable {
        MethodHandle handle = Binder
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

                .from(String[].class, String.class, String.class, String.class)
                .varargs(1, String[].class)
                .invokeStatic(LOOKUP, BinderTest.class, "varargs");

        assertEquals(MethodType.methodType(String[].class, String.class, String.class, String.class), handle.type());
        String[] ary = (String[])handle.invokeExact("one", "two", "three");
        assertEquals(2, ary.length);
        assertEquals("two", ary[0]);
        assertEquals("three", ary[1]);
    }
View Full Code Here

Examples of java.lang.invoke.MethodHandle.invokeExact()

        MethodHandle handle = Binder
                .from(String.class)
                .constant("hello");

        assertEquals(MethodType.methodType(String.class), handle.type());
        assertEquals("hello", (String)handle.invokeExact());
    }

    @Test
    public void testConstant2() throws Throwable {
        MethodHandle handle = Binder
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.