本文整理匯總了Java中java.lang.invoke.CallSite.setTarget方法的典型用法代碼示例。如果您正苦於以下問題:Java CallSite.setTarget方法的具體用法?Java CallSite.setTarget怎麽用?Java CallSite.setTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.invoke.CallSite
的用法示例。
在下文中一共展示了CallSite.setTarget方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: relinkComposableInvoker
import java.lang.invoke.CallSite; //導入方法依賴的package包/類
private static void relinkComposableInvoker(final CallSite cs, final CompiledFunction inv, final boolean constructor) {
final HandleAndAssumptions handleAndAssumptions = inv.getValidOptimisticInvocation(new Supplier<MethodHandle>() {
@Override
public MethodHandle get() {
return inv.getInvokerOrConstructor(constructor);
}
});
final MethodHandle handle = handleAndAssumptions.handle;
final SwitchPoint assumptions = handleAndAssumptions.assumptions;
final MethodHandle target;
if(assumptions == null) {
target = handle;
} else {
final MethodHandle relink = MethodHandles.insertArguments(RELINK_COMPOSABLE_INVOKER, 0, cs, inv, constructor);
target = assumptions.guardWithTest(handle, MethodHandles.foldArguments(cs.dynamicInvoker(), relink));
}
cs.setTarget(target.asType(cs.type()));
}
示例2: bootstrap
import java.lang.invoke.CallSite; //導入方法依賴的package包/類
public static CallSite bootstrap(Lookup lookup, String name, MethodType type) throws ReflectiveOperationException {
CallSite callSite = new MutableCallSite(type);
MethodHandle send = from(type)
.insert(0, lookup)
.invokeStatic(lookup, SnacksDispatcher.class, name);
callSite.setTarget(send);
return callSite;
}
示例3: LilaCallSite
import java.lang.invoke.CallSite; //導入方法依賴的package包/類
public static CallSite bootstrapCall
(Lookup lookup, String name, MethodType type)
{
CallSite callSite = new LilaCallSite(type);
MethodHandle target = fallback.bindTo(callSite)
// -1: function
.asCollector(LilaObject[].class, type.parameterCount() - 1);
callSite.setTarget(target);
return callSite;
}