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


Java GuardedInvocation.getClass方法代码示例

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


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

示例1: relink

import jdk.internal.dynalink.linker.GuardedInvocation; //导入方法依赖的package包/类
/**
 * Relinks a call site conforming to the invocation arguments.
 *
 * @param callSite the call site itself
 * @param arguments arguments to the invocation
 * @return return the method handle for the invocation
 * @throws Exception rethrows any exception thrown by the linkers
 */
@SuppressWarnings("unused")
private MethodHandle relink(final RelinkableCallSite callSite, final int relinkCount, final Object... arguments) throws Exception {
    final CallSiteDescriptor callSiteDescriptor = callSite.getDescriptor();
    final boolean unstableDetectionEnabled = unstableRelinkThreshold > 0;
    final boolean callSiteUnstable = unstableDetectionEnabled && relinkCount >= unstableRelinkThreshold;
    final LinkRequest linkRequest =
            runtimeContextArgCount == 0 ?
                    new LinkRequestImpl(callSiteDescriptor, callSite, relinkCount, callSiteUnstable, arguments) :
                    new RuntimeContextLinkRequestImpl(callSiteDescriptor, callSite, relinkCount, callSiteUnstable, arguments, runtimeContextArgCount);

    GuardedInvocation guardedInvocation = linkerServices.getGuardedInvocation(linkRequest);

    // None found - throw an exception
    if(guardedInvocation == null) {
        throw new NoSuchDynamicMethodException(callSiteDescriptor.toString());
    }

    // If our call sites have a runtime context, and the linker produced a context-stripped invocation, adapt the
    // produced invocation into contextual invocation (by dropping the context...)
    if(runtimeContextArgCount > 0) {
        final MethodType origType = callSiteDescriptor.getMethodType();
        final MethodHandle invocation = guardedInvocation.getInvocation();
        if(invocation.type().parameterCount() == origType.parameterCount() - runtimeContextArgCount) {
            final List<Class<?>> prefix = origType.parameterList().subList(1, runtimeContextArgCount + 1);
            final MethodHandle guard = guardedInvocation.getGuard();
            guardedInvocation = guardedInvocation.dropArguments(1, prefix);
        }
    }

    // Make sure we filter the invocation before linking it into the call site. This is typically used to match the
    // return type of the invocation to the call site.
    guardedInvocation = prelinkFilter.filter(guardedInvocation, linkRequest, linkerServices);
    guardedInvocation.getClass(); // null pointer check

    int newRelinkCount = relinkCount;
    // Note that the short-circuited "&&" evaluation below ensures we'll increment the relinkCount until
    // threshold + 1 but not beyond that. Threshold + 1 is treated as a special value to signal that resetAndRelink
    // has already executed once for the unstable call site; we only want the call site to throw away its current
    // linkage once, when it transitions to unstable.
    if(unstableDetectionEnabled && newRelinkCount <= unstableRelinkThreshold && newRelinkCount++ == unstableRelinkThreshold) {
        callSite.resetAndRelink(guardedInvocation, createRelinkAndInvokeMethod(callSite, newRelinkCount));
    } else {
        callSite.relink(guardedInvocation, createRelinkAndInvokeMethod(callSite, newRelinkCount));
    }
    if(syncOnRelink) {
        MutableCallSite.syncAll(new MutableCallSite[] { (MutableCallSite)callSite });
    }
    return guardedInvocation.getInvocation();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:58,代码来源:DynamicLinker.java


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