Package java.lang.invoke

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


    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "equals", BINOP_TYPE, 2).dynamicInvoker();

    assertThat((Boolean) handle.invokeWithArguments(null, null), is(true));
    assertThat((Boolean) handle.invokeWithArguments(null, "foo"), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", null), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", "foo"), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", "bar"), is(false));
  }

  @Test
  public void check_notEquals() throws Throwable {
View Full Code Here


    assertThat((Boolean) handle.invokeWithArguments(null, null), is(true));
    assertThat((Boolean) handle.invokeWithArguments(null, "foo"), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", null), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", "foo"), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", "bar"), is(false));
  }

  @Test
  public void check_notEquals() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "notequals", BINOP_TYPE, 2).dynamicInvoker();
View Full Code Here

  @Test
  public void check_notEquals() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "notequals", BINOP_TYPE, 2).dynamicInvoker();

    assertThat((Boolean) handle.invokeWithArguments(null, null), is(false));
    assertThat((Boolean) handle.invokeWithArguments(null, "foo"), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", null), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", "foo"), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", "bar"), is(true));
  }
View Full Code Here

  @Test
  public void check_notEquals() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "notequals", BINOP_TYPE, 2).dynamicInvoker();

    assertThat((Boolean) handle.invokeWithArguments(null, null), is(false));
    assertThat((Boolean) handle.invokeWithArguments(null, "foo"), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", null), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", "foo"), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", "bar"), is(true));
  }
View Full Code Here

  public void check_notEquals() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "notequals", BINOP_TYPE, 2).dynamicInvoker();

    assertThat((Boolean) handle.invokeWithArguments(null, null), is(false));
    assertThat((Boolean) handle.invokeWithArguments(null, "foo"), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", null), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", "foo"), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", "bar"), is(true));
  }

  @Test
View Full Code Here

    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "notequals", BINOP_TYPE, 2).dynamicInvoker();

    assertThat((Boolean) handle.invokeWithArguments(null, null), is(false));
    assertThat((Boolean) handle.invokeWithArguments(null, "foo"), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", null), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", "foo"), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", "bar"), is(true));
  }

  @Test
  public void check_less() throws Throwable {
View Full Code Here

    assertThat((Boolean) handle.invokeWithArguments(null, null), is(false));
    assertThat((Boolean) handle.invokeWithArguments(null, "foo"), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", null), is(true));
    assertThat((Boolean) handle.invokeWithArguments("foo", "foo"), is(false));
    assertThat((Boolean) handle.invokeWithArguments("foo", "bar"), is(true));
  }

  @Test
  public void check_less() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "less", BINOP_TYPE, 2).dynamicInvoker();
View Full Code Here

  @Test
  public void check_less() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "less", BINOP_TYPE, 2).dynamicInvoker();

    assertThat((Boolean) handle.invokeWithArguments(1, 2), is(true));
    assertThat((Boolean) handle.invokeWithArguments(1, 1), is(false));
    assertThat((Boolean) handle.invokeWithArguments(2, 1), is(false));
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
View Full Code Here

  @Test
  public void check_less() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "less", BINOP_TYPE, 2).dynamicInvoker();

    assertThat((Boolean) handle.invokeWithArguments(1, 2), is(true));
    assertThat((Boolean) handle.invokeWithArguments(1, 1), is(false));
    assertThat((Boolean) handle.invokeWithArguments(2, 1), is(false));
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void check_less_rejects_non_comparable() throws Throwable {
View Full Code Here

  public void check_less() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "less", BINOP_TYPE, 2).dynamicInvoker();

    assertThat((Boolean) handle.invokeWithArguments(1, 2), is(true));
    assertThat((Boolean) handle.invokeWithArguments(1, 1), is(false));
    assertThat((Boolean) handle.invokeWithArguments(2, 1), is(false));
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void check_less_rejects_non_comparable() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "less", BINOP_TYPE, 2).dynamicInvoker();
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.