Exemplo n.º 1
0
 private MethodHandle addReturnConversion(MethodHandle finisher, Class<?> type) {
   // FIXME: This is slow because it creates a closure node on every call that requires a return
   // cast.
   MethodType finisherType = finisher.type();
   MethodHandle caster = ValueConversions.identity(type);
   caster = caster.asType(caster.type().changeParameterType(0, finisherType.returnType()));
   finisher = MethodHandles.filterReturnValue(finisher, caster);
   return finisher.asType(finisherType);
 }
Exemplo n.º 2
0
 /**
  * Return a method handle to invoke on the callerType, target, and remaining arguments. The method
  * handle must finish the call. This is the first look at the caller type and target.
  */
 private MethodHandle dispatch(MethodType callerType, MethodHandle target) {
   MethodType targetType = target.type();
   if (USE_AS_TYPE_PATH || target.isVarargsCollector()) {
     MethodHandle newTarget = target.asType(callerType);
     targetType = callerType;
     Invokers invokers = targetType.invokers();
     MethodHandle invoker = invokers.erasedInvokerWithDrops;
     if (invoker == null) {
       invokers.erasedInvokerWithDrops = invoker = dropDispatchArguments(invokers.erasedInvoker());
     }
     return invoker.bindTo(newTarget);
   }
   throw new RuntimeException("NYI");
 }