Package org.dynalang.dynalink

Examples of org.dynalang.dynalink.DynamicLinkerFactory


public class TestElementSetter extends TestCase {
    public void testEarlyBoundPrimitiveArrayElementSetter() throws Throwable {
        final RelinkCountingCallSite cs = new RelinkCountingCallSite("dyn:setElem", MethodType.methodType(Void.TYPE,
                int[].class, int.class, int.class));
        new DynamicLinkerFactory().createLinker().link(cs);
        final MethodHandle invoker = cs.dynamicInvoker();
        final int[] x = new int[] { 0, 0, 0 };
        invoker.invokeWithArguments(x, 0, 3);
        invoker.invokeWithArguments(x, 1, 2);
        invoker.invokeWithArguments(x, 2, 1);
View Full Code Here


    }

    public void testEarlyBoundObjectArrayElementSetter() throws Throwable {
        final RelinkCountingCallSite cs = new RelinkCountingCallSite("dyn:setElem", MethodType.methodType(Void.TYPE,
                Object[].class, int.class, Object.class));
        new DynamicLinkerFactory().createLinker().link(cs);
        final MethodHandle invoker = cs.dynamicInvoker();
        final Integer[] x = new Integer[] { 0, 0, 0 };
        final String[] y = new String[] { "x", "y", "z" };
        invoker.invokeWithArguments(x, 0, 3);
        invoker.invokeWithArguments(x, 1, 2);
View Full Code Here

    }

    public void testEarlyBoundListElementSetter() throws Throwable {
        final RelinkCountingCallSite cs = new RelinkCountingCallSite("dyn:setElem", MethodType.methodType(Void.TYPE,
                List.class, int.class, Object.class));
        new DynamicLinkerFactory().createLinker().link(cs);
        final MethodHandle invoker = cs.dynamicInvoker();
        final List<Integer> x = Arrays.asList(new Integer[] { 0, 0, 0 });
        final List<String> y = Arrays.asList(new String[] { "x", "y", "z" });
        invoker.invokeWithArguments(x, 0, 3);
        invoker.invokeWithArguments(x, 1, 2);
View Full Code Here

    }

    public void testEarlyBoundMapElementSetter() throws Throwable {
        final RelinkCountingCallSite cs = new RelinkCountingCallSite("dyn:setElem", MethodType.methodType(Void.TYPE,
                Map.class, Object.class, Object.class));
        new DynamicLinkerFactory().createLinker().link(cs);
        final MethodHandle invoker = cs.dynamicInvoker();
        final Map<Integer, Integer> x = new HashMap<Integer, Integer>();
        final Map<String, String> y = new TreeMap<String, String>();
        invoker.invokeWithArguments(x, 0, 3);
        invoker.invokeWithArguments(x, 1, 2);
View Full Code Here

    public void testLateBoundMapElementSetter() throws Throwable {
        final RelinkCountingCallSite cs =
                new RelinkCountingCallSite("dyn:setElem", MethodType.methodType(Void.TYPE, Object.class, Object.class,
                        Object.class));
        new DynamicLinkerFactory().createLinker().link(cs);
        final MethodHandle invoker = cs.dynamicInvoker();
        final Map<Integer, Integer> x = new HashMap<Integer, Integer>();
        final Map<String, String> y = new TreeMap<String, String>();
        invoker.invokeWithArguments(x, 0, 3);
        invoker.invokeWithArguments(x, 1, 2);
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),
View Full Code Here

TOP

Related Classes of org.dynalang.dynalink.DynamicLinkerFactory

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.