Package org.dynalang.dynalink

Examples of org.dynalang.dynalink.DynamicLinker


        assertEquals(0, mh.invokeWithArguments(Collections.EMPTY_MAP));
        assertEquals(1, mh.invokeWithArguments(Collections.singletonMap("a", "b")));
    }

    public void testLateBoundLengthGetter() throws Throwable {
        final DynamicLinker linker = new DynamicLinkerFactory().createLinker();
        final RelinkCountingCallSite callSite =
                new RelinkCountingCallSite("dyn:getLength", MethodType.methodType(int.class, Object.class));

        linker.link(callSite);
        assertEquals(0, callSite.getRelinkCount());
        MethodHandle callSiteInvoker = callSite.dynamicInvoker();
        assertEquals(2, callSiteInvoker.invokeWithArguments(new int[2]));
        assertEquals(1, callSite.getRelinkCount());
        assertEquals(3, callSiteInvoker.invokeWithArguments(new Object[] { new Object[3] }));
View Full Code Here


        // Must be able to invoke it with explicitly packed varargs
        assertEquals(4, mh.invokeWithArguments(new Test1(), 1, new int[] { 2 }));
    }

    public void testStringFormat() throws Throwable {
        DynamicLinker linker = new DynamicLinkerFactory().createLinker();
        MonomorphicCallSite callSite = new MonomorphicCallSite(CallSiteDescriptorFactory.create(
                MethodHandles.publicLookup(), "dyn:callMethod:format", MethodType.methodType(Object.class,
                        Object.class, Object.class, Object.class, Object.class)));
        linker.link(callSite);
        System.out.println(callSite.dynamicInvoker().invokeWithArguments(StaticClass.forClass(String.class),
                "%4.0f %4.0f", 12f, 1f));
    }
View Full Code Here

TOP

Related Classes of org.dynalang.dynalink.DynamicLinker

Copyright © 2018 www.massapicom. 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.