Package java.lang.invoke

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


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

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

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


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

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

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void check_moreOrEquals_rejects_non_comparable() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "moreorequals", BINOP_TYPE, 2).dynamicInvoker();
View Full Code Here

  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void check_moreOrEquals_rejects_non_comparable() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "moreorequals", BINOP_TYPE, 2).dynamicInvoker();
    handle.invokeWithArguments(new Object(), new Object());
  }

  @Test
  public void check_not() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "not", UNOP_TYPE, 1).dynamicInvoker();
View Full Code Here

  }

  @Test
  public void check_not() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "not", UNOP_TYPE, 1).dynamicInvoker();
    assertThat((Boolean) handle.invokeWithArguments(true), is(false));
    assertThat((Boolean) handle.invokeWithArguments(false), is(true));
  }

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

  @Test
  public void check_not() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "not", UNOP_TYPE, 1).dynamicInvoker();
    assertThat((Boolean) handle.invokeWithArguments(true), is(false));
    assertThat((Boolean) handle.invokeWithArguments(false), is(true));
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void check_not_rejects_non_booleans() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "not", UNOP_TYPE, 1).dynamicInvoker();
View Full Code Here

  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void check_not_rejects_non_booleans() throws Throwable {
    MethodHandle handle = OperatorSupport.bootstrap(lookup(), "not", UNOP_TYPE, 1).dynamicInvoker();
    handle.invokeWithArguments("foo");
  }

  @Test
  public void check_is_and_isnt() throws Throwable {
    Object a = new Object();
View Full Code Here

  public void check_is_and_isnt() throws Throwable {
    Object a = new Object();
    Object b = new Object();

    MethodHandle is = OperatorSupport.bootstrap(lookup(), "is", BINOP_TYPE, 2).dynamicInvoker();
    assertThat((Boolean) is.invokeWithArguments(a, a), is(true));
    assertThat((Boolean) is.invokeWithArguments(a, b), is(false));

    MethodHandle isnt = OperatorSupport.bootstrap(lookup(), "isnt", BINOP_TYPE, 2).dynamicInvoker();
    assertThat((Boolean) isnt.invokeWithArguments(a, a), is(false));
    assertThat((Boolean) isnt.invokeWithArguments(a, b), is(true));
View Full Code Here

    Object a = new Object();
    Object b = new Object();

    MethodHandle is = OperatorSupport.bootstrap(lookup(), "is", BINOP_TYPE, 2).dynamicInvoker();
    assertThat((Boolean) is.invokeWithArguments(a, a), is(true));
    assertThat((Boolean) is.invokeWithArguments(a, b), is(false));

    MethodHandle isnt = OperatorSupport.bootstrap(lookup(), "isnt", BINOP_TYPE, 2).dynamicInvoker();
    assertThat((Boolean) isnt.invokeWithArguments(a, a), is(false));
    assertThat((Boolean) isnt.invokeWithArguments(a, b), is(true));
  }
View Full Code Here

    MethodHandle is = OperatorSupport.bootstrap(lookup(), "is", BINOP_TYPE, 2).dynamicInvoker();
    assertThat((Boolean) is.invokeWithArguments(a, a), is(true));
    assertThat((Boolean) is.invokeWithArguments(a, b), is(false));

    MethodHandle isnt = OperatorSupport.bootstrap(lookup(), "isnt", BINOP_TYPE, 2).dynamicInvoker();
    assertThat((Boolean) isnt.invokeWithArguments(a, a), is(false));
    assertThat((Boolean) isnt.invokeWithArguments(a, b), is(true));
  }

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

    assertThat((Boolean) is.invokeWithArguments(a, a), is(true));
    assertThat((Boolean) is.invokeWithArguments(a, b), is(false));

    MethodHandle isnt = OperatorSupport.bootstrap(lookup(), "isnt", BINOP_TYPE, 2).dynamicInvoker();
    assertThat((Boolean) isnt.invokeWithArguments(a, a), is(false));
    assertThat((Boolean) isnt.invokeWithArguments(a, b), is(true));
  }

  @Test
  public void check_oftype() throws Throwable {
    String str = "abc";
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.