当前位置: 首页>>代码示例>>Java>>正文


Java SwitchPoint.guardWithTest方法代码示例

本文整理汇总了Java中java.lang.invoke.SwitchPoint.guardWithTest方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchPoint.guardWithTest方法的具体用法?Java SwitchPoint.guardWithTest怎么用?Java SwitchPoint.guardWithTest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.invoke.SwitchPoint的用法示例。


在下文中一共展示了SwitchPoint.guardWithTest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: relinkComposableInvoker

import java.lang.invoke.SwitchPoint; //导入方法依赖的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()));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:CompiledFunction.java

示例2: compose

import java.lang.invoke.SwitchPoint; //导入方法依赖的package包/类
/**
 * Composes the invocation, switchpoint, and the guard into a composite method handle that knows how to fall back.
 * @param switchpointFallback the fallback method handle in case switchpoint is invalidated.
 * @param guardFallback the fallback method handle in case guard returns false.
 * @param catchFallback the fallback method in case the exception handler triggers
 * @return a composite method handle.
 */
public MethodHandle compose(final MethodHandle guardFallback, final MethodHandle switchpointFallback, final MethodHandle catchFallback) {
    final MethodHandle guarded =
            guard == null ?
                    invocation :
                    MethodHandles.guardWithTest(
                            guard,
                            invocation,
                            guardFallback);

    final MethodHandle catchGuarded =
            exception == null ?
                    guarded :
                    MH.catchException(
                            guarded,
                            exception,
                            MethodHandles.dropArguments(
                                catchFallback,
                                0,
                                exception));

    if (switchPoints == null) {
        return catchGuarded;
    }

    MethodHandle spGuarded = catchGuarded;
    for (final SwitchPoint sp : switchPoints) {
        spGuarded = sp.guardWithTest(spGuarded, switchpointFallback);
    }

    return spGuarded;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:GuardedInvocation.java

示例3: compose

import java.lang.invoke.SwitchPoint; //导入方法依赖的package包/类
/**
 * Composes the invocation, guard, switch points, and the exception into a
 * composite method handle that knows how to fall back when the guard fails
 * or the invocation is invalidated.
 * @param switchpointFallback the fallback method handle in case a switch
 * point is invalidated.
 * @param guardFallback the fallback method handle in case guard returns
 * false.
 * @param catchFallback the fallback method in case the exception handler
 * triggers.
 * @return a composite method handle.
 */
public MethodHandle compose(final MethodHandle guardFallback, final MethodHandle switchpointFallback, final MethodHandle catchFallback) {
    final MethodHandle guarded =
            guard == null ?
                    invocation :
                    MethodHandles.guardWithTest(
                            guard,
                            invocation,
                            guardFallback);

    final MethodHandle catchGuarded =
            exception == null ?
                    guarded :
                    MethodHandles.catchException(
                            guarded,
                            exception,
                            MethodHandles.dropArguments(
                                catchFallback,
                                0,
                                exception));

    if (switchPoints == null) {
        return catchGuarded;
    }

    MethodHandle spGuarded = catchGuarded;
    for (final SwitchPoint sp : switchPoints) {
        spGuarded = sp.guardWithTest(spGuarded, switchpointFallback);
    }

    return spGuarded;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:GuardedInvocation.java

示例4: guardWithTest

import java.lang.invoke.SwitchPoint; //导入方法依赖的package包/类
@Override
public MethodHandle guardWithTest(final SwitchPoint sp, final MethodHandle before, final MethodHandle after) {
    final MethodHandle mh = sp.guardWithTest(before, after);
    return debug(mh, "guardWithTest", sp, before, after);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:MethodHandleFactory.java


注:本文中的java.lang.invoke.SwitchPoint.guardWithTest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。