Examples of invokeExact()


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

  public static void timeUnReflectionCached(IndyDemo indyDemo) throws Throwable {
    long start = System.currentTimeMillis();
    MethodHandles.Lookup lookup = MethodHandles.lookup();
    MethodHandle someMethod = lookup.unreflect(IndyDemo.class.getDeclaredMethod("someMethod"));
    for (int i = 0; i < TIMES; i++) {
      int result = (int) someMethod.invokeExact(indyDemo);
    }
    System.out.println("unreflection cached: " + (System.currentTimeMillis() - start));
  }

  public static void timeMH(IndyDemo indyDemo) throws Throwable {
View Full Code Here

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

    long start = System.currentTimeMillis();
    MethodHandles.Lookup lookup = MethodHandles.lookup();
    MethodType type = MethodType.methodType(Integer.TYPE);
    MethodHandle someMethod = lookup.findVirtual(IndyDemo.class, "someMethod", type);
    for (int i = 0; i < TIMES; i++) {
      int result = (int) someMethod.invokeExact(indyDemo);
    }
    System.out.println("methodhandle cached: " + (System.currentTimeMillis() - start));
  }

  public static void timeDirect(IndyDemo indyDemo) throws Throwable {
View Full Code Here

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

    final MethodHandle constr = findAttributeImplCtor(clazz);
    return new StaticImplementationAttributeFactory<A>(delegate, clazz) {
      @Override
      protected A createInstance() {
        try {
          return (A) constr.invokeExact();
        } catch (Throwable t) {
          rethrow(t);
          throw new AssertionError();
        }
      }
View Full Code Here

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

        final Delegate delegate = outer.compileDelegate();
        final MethodHandle handle = delegate.getMethodHandle();

        System.out.printf("\n[%s]\n", handle.getClass().getSimpleName());

        final int result = (int) handle.invokeExact();

        System.out.println(result);

        assertEquals(expectedResult, result);
    }
View Full Code Here

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

        final MethodHandle getter = MethodHandles.lookup().findStaticGetter(
            generatedType.getErasedClass(),
            "Numbers",
            int[].class);

        final int[] numbers = (int[])getter.invokeExact();

        assertArrayEquals(new int[] { 1, 2, 3, 4, 5 }, numbers);
    }
   
    @Test
View Full Code Here

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

  @Test
  public void test_golo_loading() throws Throwable {
    CodeLoader loader = new CodeLoader();

    MethodHandle truth = loader.golo("check", "truth", 0);
    assertEquals(42, (Object) truth.invokeExact());

    MethodHandle incr = loader.golo("check", "incr", 1);
    assertEquals(42, (Object) incr.invokeExact((Object) 41));
  }
View Full Code Here

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

    MethodHandle truth = loader.golo("check", "truth", 0);
    assertEquals(42, (Object) truth.invokeExact());

    MethodHandle incr = loader.golo("check", "incr", 1);
    assertEquals(42, (Object) incr.invokeExact((Object) 41));
  }

  @Test
  public void test_groovy_loading() throws Throwable {
    CodeLoader loader = new CodeLoader();
View Full Code Here

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

  @Test
  public void test_groovy_loading() throws Throwable {
    CodeLoader loader = new CodeLoader();

    MethodHandle truth = loader.groovy("Check", "truth", genericMethodType(0));
    assertEquals(42, (Object) truth.invokeExact());

    MethodHandle incr = loader.groovy("Check", "incr", genericMethodType(1));
    assertEquals(42, (Object) incr.invokeExact((Object) 41));
  }
View Full Code Here

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

    MethodHandle truth = loader.groovy("Check", "truth", genericMethodType(0));
    assertEquals(42, (Object) truth.invokeExact());

    MethodHandle incr = loader.groovy("Check", "incr", genericMethodType(1));
    assertEquals(42, (Object) incr.invokeExact((Object) 41));
  }

  @Test
  public void test_groovy_indy_loading() throws Throwable {
    CodeLoader loader = new CodeLoader();
View Full Code Here

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

  @Test
  public void test_groovy_indy_loading() throws Throwable {
    CodeLoader loader = new CodeLoader();

    MethodHandle truth = loader.groovy_indy("Check", "truth", genericMethodType(0));
    assertEquals(42, (Object) truth.invokeExact());

    MethodHandle incr = loader.groovy_indy("Check", "incr", genericMethodType(1));
    assertEquals(42, (Object) incr.invokeExact((Object) 41));
  }
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.