Package java.lang.invoke

Examples of java.lang.invoke.CallSite.dynamicInvoker()


    CallSite callSite = FunctionCallSupport.bootstrap(lookup, name, type);
    assertThat((String) callSite.dynamicInvoker().invokeWithArguments("a", "b", "c"), is("a-b-c"));

    type = MethodType.methodType(Object.class, Object.class);
    callSite = FunctionCallSupport.bootstrap(lookup, name, type);
    assertThat((String) callSite.dynamicInvoker().invokeWithArguments("a"), is("a"));

    type = MethodType.methodType(Object.class);
    callSite = FunctionCallSupport.bootstrap(lookup, name, type);
    assertThat((String) callSite.dynamicInvoker().invokeWithArguments(), is(""));
View Full Code Here


    callSite = FunctionCallSupport.bootstrap(lookup, name, type);
    assertThat((String) callSite.dynamicInvoker().invokeWithArguments("a"), is("a"));

    type = MethodType.methodType(Object.class);
    callSite = FunctionCallSupport.bootstrap(lookup, name, type);
    assertThat((String) callSite.dynamicInvoker().invokeWithArguments(), is(""));

    type = MethodType.methodType(Object.class, Object.class);
    callSite = FunctionCallSupport.bootstrap(lookup, name, type);
    assertThat((String) callSite.dynamicInvoker().invokeWithArguments((Object)new String[]{"a", "b", "c"}), is("a-b-c"));
  }
View Full Code Here

    callSite = FunctionCallSupport.bootstrap(lookup, name, type);
    assertThat((String) callSite.dynamicInvoker().invokeWithArguments(), is(""));

    type = MethodType.methodType(Object.class, Object.class);
    callSite = FunctionCallSupport.bootstrap(lookup, name, type);
    assertThat((String) callSite.dynamicInvoker().invokeWithArguments((Object)new String[]{"a", "b", "c"}), is("a-b-c"));
  }
}
View Full Code Here

  @Test
  public void check_bootstrap() throws Throwable {
    MethodHandle handle = lookup().findStatic(ClosureCallSupportTest.class, "objectToString", genericMethodType(1));
    CallSite callSite = ClosureCallSupport.bootstrap(lookup(), "closure", methodType(Object.class, MethodHandle.class, Object.class));

    MethodHandle invoker = callSite.dynamicInvoker();
    assertThat((String) invoker.invokeWithArguments(handle, 123), is("123"));
    assertThat((String) invoker.invokeWithArguments(handle, 123), is("123"));

    handle = lookup().findStatic(ClosureCallSupportTest.class, "objectToStringDecorated", genericMethodType(1));
    assertThat((String) invoker.invokeWithArguments(handle, 123), is("[123]"));
View Full Code Here

  @Test
  public void check_bootstrap_varargs() throws Throwable {
    MethodHandle handle = lookup().findStatic(ClosureCallSupportTest.class, "concat", genericMethodType(0, true));
    CallSite callSite = ClosureCallSupport.bootstrap(lookup(), "closure", methodType(Object.class, MethodHandle.class, Object.class, Object.class));
    MethodHandle invoker = callSite.dynamicInvoker();
    assertThat((String) invoker.invokeWithArguments(handle, 1, 2), is("12"));

    handle = lookup().findStatic(ClosureCallSupportTest.class, "concat", genericMethodType(0, true));
    callSite = ClosureCallSupport.bootstrap(lookup(), "closure", methodType(Object.class, MethodHandle.class, Object.class));
    invoker = callSite.dynamicInvoker();
View Full Code Here

    MethodHandle invoker = callSite.dynamicInvoker();
    assertThat((String) invoker.invokeWithArguments(handle, 1, 2), is("12"));

    handle = lookup().findStatic(ClosureCallSupportTest.class, "concat", genericMethodType(0, true));
    callSite = ClosureCallSupport.bootstrap(lookup(), "closure", methodType(Object.class, MethodHandle.class, Object.class));
    invoker = callSite.dynamicInvoker();
    assertThat((String) invoker.invokeWithArguments(handle, 1), is("1"));

    handle = lookup().findStatic(ClosureCallSupportTest.class, "concat", genericMethodType(0, true));
    callSite = ClosureCallSupport.bootstrap(lookup(), "closure", methodType(Object.class, MethodHandle.class));
    invoker = callSite.dynamicInvoker();
View Full Code Here

    invoker = callSite.dynamicInvoker();
    assertThat((String) invoker.invokeWithArguments(handle, 1), is("1"));

    handle = lookup().findStatic(ClosureCallSupportTest.class, "concat", genericMethodType(0, true));
    callSite = ClosureCallSupport.bootstrap(lookup(), "closure", methodType(Object.class, MethodHandle.class));
    invoker = callSite.dynamicInvoker();
    assertThat((String) invoker.invokeWithArguments(handle), is(""));

    handle = lookup().findStatic(ClosureCallSupportTest.class, "concat", genericMethodType(0, true));
    callSite = ClosureCallSupport.bootstrap(lookup(), "closure", methodType(Object.class, MethodHandle.class, Object.class));
    invoker = callSite.dynamicInvoker();
View Full Code Here

    invoker = callSite.dynamicInvoker();
    assertThat((String) invoker.invokeWithArguments(handle), is(""));

    handle = lookup().findStatic(ClosureCallSupportTest.class, "concat", genericMethodType(0, true));
    callSite = ClosureCallSupport.bootstrap(lookup(), "closure", methodType(Object.class, MethodHandle.class, Object.class));
    invoker = callSite.dynamicInvoker();
    assertThat((String) invoker.invokeWithArguments(handle, new Object[]{1,2}), is("12"));
  }
}
View Full Code Here

  }

  @Test
  public void check_to_string() throws Throwable {
    CallSite toString = MethodInvocationSupport.bootstrap(lookup(), "toString", methodType(Object.class, Object.class), 0);
    String result = (String) toString.dynamicInvoker().invokeWithArguments(julien());
    assertThat(result, notNullValue());
    assertThat(result, is("Person{name='Julien', email='julien.ponge@insa-lyon.fr'}"));
  }

  @Test
View Full Code Here

  @Test
  public void check_set_name() throws Throwable {
    CallSite setName = MethodInvocationSupport.bootstrap(lookup(), "setName", methodType(Object.class, Object.class, Object.class), 0);
    Person julien = julien();
    setName.dynamicInvoker().invokeWithArguments(julien, "Julien Ponge");
    assertThat(julien.name, is("Julien Ponge"));
  }

  @Test
  public void check_equals() throws Throwable {
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.