Examples of MethodHandle


Examples of java.lang.invoke.MethodHandle

    cache = ArrayExtensions.copyWith_(cache, new CacheEntry(receiverClass,
        castHandle));
  }

  private void setTargetFromCache() {
    MethodHandle sum = fallback;
    for (int i = cache.length - 1; i >= 0; i--) {
      CacheEntry entry = cache[i];
      sum = getGuardedMethod(entry, sum);
    }
    setTarget(sum);
View Full Code Here

Examples of java.lang.invoke.MethodHandle

  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));
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle

        .value_(namespaceString);
    AbsoluteReference fullReference = namespace.$slash$(Symbol
        .value(selector));
    final AlmostFinalValue singletonHolder = ImageBootstrapper.systemMapping
        .resolveSingletonHolder_(fullReference);
    final MethodHandle target = lookup.findVirtual(
        AlmostFinalValue.class,
        "setValue",
        MethodType.methodType(Object.class, Object.class)).bindTo(singletonHolder);
    return new ConstantCallSite(target);
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle

      if (selector.equals("doesNotUnderstand_"))
        throw new RuntimeException("Can't find DNU method");
      return wrapDNUHandle(lookupMethod(receiverClass,
          "doesNotUnderstand_"));
    }
    MethodHandle methodHandle;
    try {
      Method method = MethodTools.searchForMethod(
          mapping.definingClass(), selector, type.parameterArray(),
          true);

      if (method != null) {
        return mapping.methodHandle().asType(type);
      }
      methodHandle = lookup.findSpecial(mapping.definingClass(),
          selector, type.dropParameterTypes(0, 1), lookup.lookupClass());
    } catch (NoSuchMethodException | IllegalAccessException r) {

      try {
        methodHandle = lookup.findStatic(mapping.definingClass(),
            selector, type);
      } catch (NoSuchMethodException | IllegalAccessException e) {

        throw new RuntimeException(e);
      }
    }
    return methodHandle.asType(type);
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle

  }

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

Examples of java.lang.invoke.MethodHandle

      String selector) {
    super(lookup, type, selector);
  }

  protected MethodHandle findMethodForNil() {
    MethodHandle methodHandle = ImageBootstrapper.systemMapping
        .methodHandleForNil_(selector);
    if (methodHandle == null) {
      return createDNUHandleForNil();
    }
    MethodHandle castHandle = methodHandle.asType(type);
    return castHandle;
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle

    MethodHandle castHandle = methodHandle.asType(type);
    return castHandle;
  }

  protected MethodHandle findMethod(final Class receiverClass) {
    MethodHandle methodHandle = ImageBootstrapper.systemMapping
        .methodHandleFor_methodName_(receiverClass, selector);
    if (methodHandle == null) {
      methodHandle = createDNUHandle(receiverClass);
    }
    MethodHandle castHandle = methodHandle.asType(type);
    return castHandle;
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle

    MethodHandle castHandle = methodHandle.asType(type);
    return castHandle;
  }

  public MethodHandle createDNUHandleForNil() {
    MethodHandle dnuHandle = ImageBootstrapper.systemMapping
        .methodHandleForNil_("doesNotUnderstand_arguments_");
    return wrapDNUHandle(dnuHandle);
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle

        .methodHandleForNil_("doesNotUnderstand_arguments_");
    return wrapDNUHandle(dnuHandle);
  }

  public MethodHandle createDNUHandle(final Class receiverClass) {
    MethodHandle dnuHandle = ImageBootstrapper.systemMapping
        .methodHandleFor_methodName_(receiverClass,
            "doesNotUnderstand_arguments_");
    return wrapDNUHandle(dnuHandle);
  }
View Full Code Here

Examples of java.lang.invoke.MethodHandle

  protected final MethodHandles.Lookup lookup;
  protected final MethodType type;

  public MethodHandle wrapDNUHandle(MethodHandle dnuHandle) {
    Symbol sym = selectorConverter.functionNameAsSelector_(selector);
    MethodHandle withBoundSymbol = MethodHandles.insertArguments(dnuHandle,
        1, sym);
    MethodHandle message = withBoundSymbol.asCollector(Object[].class,
        numArgs());
    return message;
  }
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.