Package java.lang.invoke

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


    MethodHandle test = entry.receiverClass == null ? NIL_TEST_METHOD_HANDLE
         : MethodHandles.insertArguments(
        TYPE_TEST_METHOD_HANDLE, 1, entry.receiverClass);
    Class[] tail = ArrayExtensions.tail(type.parameterArray());
    test = MethodHandles.dropArguments(test, 1, tail);
    test = test.asType(MethodType.methodType(Boolean.TYPE,
        type.parameterArray()));
    MethodHandle guard1 = MethodHandles.guardWithTest(test,
        entry.methodHandle, fallback);
    return guard1;
  }
View Full Code Here


  public static CallSite constructorBootstrap(Lookup lookup, String selector,
      MethodType type, String referenceString) throws Throwable {
    Reference reference = Reference.factory.value_(referenceString);
    Constructor constructor = ImageBootstrapper.systemMapping.classMappingAtReference_(reference).identityClass().getConstructor();
    MethodHandle constructorHandle = lookup.unreflectConstructor(constructor);
    return new ConstantCallSite(constructorHandle.asType(type));
  }

  public static CallSite superBootstrap(Lookup lookup, String selector,
      MethodType type, String lookupStart) throws Throwable {
    SuperCallSite site = SuperCallSite.newInstance(type, lookupStart,
View Full Code Here

      } catch (NoSuchMethodException | IllegalAccessException e) {

        throw new RuntimeException(e);
      }
    }
    return methodHandle.asType(type);
  }

  @Override
  protected void addTargetToCache(Object receiver) {
    Class receiverClass = receiver.getClass();
View Full Code Here

          type.parameterCount()).insertParameterTypes(0,
          BaseCallSite.class);
      final MethodHandle fallbackHandle = MethodHandles.insertArguments(
          MethodHandles.lookup().findStatic(BaseCallSite.class,
              "invocationFallback", fallbackType), 0, this);
      return fallbackHandle.asType(type);
    } catch (NoSuchMethodException | IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

  protected MethodHandle findFieldAccess(Class receiverClass) {
    MethodHandle access = findAccessOrNil(receiverClass);
    if (access == null)
      throw new RuntimeException("Access not found");
    return access.asType(type);
  }

  protected MethodHandle findAccessOrNil(Class receiverClass) {
    // Try to find the highest defined access
    MethodHandle found = null;
View Full Code Here

        MethodHandle handle;

        handle = lookup.findStatic(Bootstrap.class, operation, type.insertParameterTypes(0, VariableSite.class));

        handle = handle.bindTo(site);
        site.setTarget(handle.asType(site.type()));

        return site;
    }

    public static CallSite searchConst(Lookup lookup, String name, MethodType type) {
View Full Code Here

        @Override
        public FunctionBinding bindFunction(long bindingId, String name, ByteCodeNode getSessionByteCode, List<ByteCodeNode> arguments)
        {
            MethodHandle methodHandle = inMethod.bindTo(constantValues);
            methodHandle = methodHandle.asType(MethodType.methodType(boolean.class, valueType));
            return new FunctionBinding(bindingId, name, new ConstantCallSite(methodHandle), arguments, false);
        }

        public static boolean in(ImmutableSet<?> set, Object value)
        {
View Full Code Here

        @Override
        public FunctionBinding bindFunction(long bindingId, String name, ByteCodeNode getSessionByteCode, List<ByteCodeNode> arguments)
        {
            MethodHandle methodHandle = inMethod.bindTo(constantValues);
            methodHandle = methodHandle.asType(MethodType.methodType(boolean.class, valueType));
            return new FunctionBinding(bindingId, name, new ConstantCallSite(methodHandle), arguments, false);
        }

        public static boolean in(ImmutableSet<?> set, Object value)
        {
View Full Code Here

            "get",
            methodType(Object.class, Object.class)
        );

        return insertArguments(
            get.asType(
                get.type()
                   .changeReturnType(boolean.class)
                   .changeParameterType(
                       1,
                       String.class
View Full Code Here

            if (receiver instanceof GroovyObject) {
                GroovyObject go = (GroovyObject) receiver;
                MetaClass mc = (MetaClass) go.getMetaClass();
                MethodHandle test = SAME_MC.bindTo(mc);
                // drop dummy receiver
                test = test.asType(MethodType.methodType(boolean.class,targetType.parameterType(0)));
                handle = MethodHandles.guardWithTest(test, handle, fallback);
                if (LOG_ENABLED) LOG.info("added meta class equality check");
            } else if (receiver instanceof Class) {
                MethodHandle test = EQUALS.bindTo(receiver);
                test = test.asType(MethodType.methodType(boolean.class,targetType.parameterType(0)));
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.