Examples of invokeExact()


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

    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));
  }

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

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

    if (value != null || object.properties.containsKey(property)) {
      if (value instanceof MethodHandle) {
        MethodHandle handle = (MethodHandle) value;
        if (handle.type().parameterCount() == 2) {
          if (handle.isVarargsCollector() && arg instanceof Object[]) {
            return handle.invokeExact((Object) object, (Object[]) arg);
          }
          return handle.invokeWithArguments(object, arg);
        }
      }
    }
View Full Code Here

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

  /* ................................................................................................................ */

  public static Object dispatchHashMap(HashMap<String, Object> map, String handleKey, String argKey) throws Throwable {
    MethodHandle handle = (MethodHandle) map.get(handleKey);
    return handle.invokeExact((Object) map.get(argKey));
  }

  public static Object callNextInt(Object obj) {
    return ((Random) obj).nextInt();
  }
View Full Code Here

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

    mh2 = lookup().findStaticSetter(Integer.class, "TYPE", Class.class);
    Field fld1 = Union1.class.getDeclaredField("field1");
    Field fld2 = Union2.class.getDeclaredField("field1");
    Class classInt = int.class;
    Class classDouble = double.class;
    mh1.invokeExact(int.class);
    mh2.invokeExact((Class)null);
    Union1 u1 = new Union1();
    u1.field2 = System.class;
    Union2 u2 = new Union2();
    fld2.set(u2, fld1.get(u1));
View Full Code Here

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

    mh2.invokeExact((Class)null);
    Union1 u1 = new Union1();
    u1.field2 = System.class;
    Union2 u2 = new Union2();
    fld2.set(u2, fld1.get(u1));
    mh1.invokeExact(classDouble);
    mh2.invokeExact(classInt);
    if (u2.field2.f29 == System.getSecurityManager()) {
      u2.field2.f29 = null;
    } else if (u2.field2.f30 == System.getSecurityManager()) {
      u2.field2.f30 = null;
View Full Code Here

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

    public static CallSite bootstrap(MethodHandles.Lookup callerLookup, String name, MethodType type, long bindingId)
    {
        try {
            MethodHandle handle = callerLookup.findStaticGetter(callerLookup.lookupClass(), CALL_SITES_FIELD_NAME, Map.class);
            Map<Long, MethodHandle> bindings = (Map<Long, MethodHandle>) handle.invokeExact();
            checkNotNull(bindings, "'callSites' field in %s is null", callerLookup.lookupClass().getName());

            MethodHandle method = bindings.get(bindingId);
            checkArgument(method != null, "Binding %s for function %s%s not found", bindingId, name, type.parameterList());
            return new ConstantCallSite(method);
View Full Code Here

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

        return methodHandleFactory.create(instance.getClass(), method);
      }
    };
    MethodHandle methodHandle = cache.fetch(method,newMethodHandleIfNotExists);
    try {
      return (T) methodHandle.invokeExact(instance, args);
    } catch (Throwable e) {
      Throwables.propagateIfPossible(e);
      throw new MethodExecutorException(e);
    }
  }
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()

            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()

        );

        final MethodHandle handle = lambda.compileHandle();

        assertEquals(AncestorClass.class, handle.type().returnType());
        assertSame(derivedClass.createType(), Type.of(((AncestorClass)handle.invokeExact()).getClass()));
    }

    static class AncestorClass {}
    static class BaseClass extends AncestorClass {}
}
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.