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


Java MethodHandleFactory类代码示例

本文整理汇总了Java中jdk.nashorn.internal.lookup.MethodHandleFactory的典型用法代码示例。如果您正苦于以下问题:Java MethodHandleFactory类的具体用法?Java MethodHandleFactory怎么用?Java MethodHandleFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: constantGetter

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private MethodHandle constantGetter(final Object c) {
    final MethodHandle mh = staticConstantGetter(c);
    if (log.isEnabled()) {
        return MethodHandleFactory.addDebugPrintout(log, Level.FINEST, mh, "getting as constant");
    }
    return mh;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:GlobalConstants.java

示例2: findOwnMH

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    try {
        return MH.findStatic(MethodHandles.lookup(), LinkerCallSite.class, name, MH.type(rtype, types));
    } catch (final MethodHandleFactory.LookupException e) {
        return MH.findVirtual(MethodHandles.lookup(), LinkerCallSite.class, name, MH.type(rtype, types));
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:8,代码来源:LinkerCallSite.java

示例3: findMH

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private static MethodHandle findMH(final String name, final Class<?> target, final Class<?> rtype, final Class<?>... types) {
    final MethodType mt  = MH.type(rtype, types);
    try {
        return MH.findStatic(MethodHandles.lookup(), target, name, mt);
    } catch (final MethodHandleFactory.LookupException e) {
        return MH.findVirtual(MethodHandles.lookup(), target, name, mt);
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:9,代码来源:JSObjectLinker.java

示例4: debug

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private MethodHandle debug(final MethodHandle mh, final Class<?> forType, final Class<?> type, final String tag) {
    if (DEBUG_FIELDS) {
       return MethodHandleFactory.addDebugPrintout(
           LOG,
           mh,
           tag + " '" + getKey() + "' (property="+ Debug.id(this) + ", forType=" + stripName(forType) + ", type=" + stripName(type) + ')');
    }
    return mh;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:10,代码来源:AccessorProperty.java

示例5: findOwnMH

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    final Class<?>   own = ScriptObject.class;
    final MethodType mt  = MH.type(rtype, types);
    try {
        return MH.findStatic(MethodHandles.lookup(), own, name, mt);
    } catch (final MethodHandleFactory.LookupException e) {
        return MH.findVirtual(MethodHandles.lookup(), own, name, mt);
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:10,代码来源:ScriptObject.java

示例6: findOwnMH

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    final Class<?>   own = ScriptFunction.class;
    final MethodType mt  = MH.type(rtype, types);
    try {
        return MH.findStatic(MethodHandles.lookup(), own, name, mt);
    } catch (final MethodHandleFactory.LookupException e) {
        return MH.findVirtual(MethodHandles.lookup(), own, name, mt);
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:10,代码来源:ScriptFunction.java

示例7: findOwnMH

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    try {
        return MH.findStatic(MethodHandles.lookup(), RuntimeCallSite.class, name, MH.type(rtype, types));
    } catch (final MethodHandleFactory.LookupException e) {
        return MH.findVirtual(MethodHandles.lookup(), RuntimeCallSite.class, name, MH.type(rtype, types));
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:8,代码来源:RuntimeCallSite.java

示例8: findOwnMH

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    final Class<?>   own = JSObjectLinker.class;
    final MethodType mt  = MH.type(rtype, types);
    try {
        return MH.findStatic(MethodHandles.lookup(), own, name, mt);
    } catch (final MethodHandleFactory.LookupException e) {
        return MH.findVirtual(MethodHandles.lookup(), own, name, mt);
    }
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:10,代码来源:JSObjectLinker.java

示例9: findJSObjectMH

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private static MethodHandle findJSObjectMH(final String name, final Class<?> rtype, final Class<?>... types) {
    final Class<?>   own = JSObject.class;
    final MethodType mt  = MH.type(rtype, types);
    try {
        return MH.findVirtual(MethodHandles.publicLookup(), own, name, mt);
    } catch (final MethodHandleFactory.LookupException e) {
        return MH.findVirtual(MethodHandles.lookup(), own, name, mt);
    }
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:10,代码来源:JSObjectLinker.java

示例10: findGetMethod

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
/**
 * Try to turn a getter into a MethodHandle.constant, if possible
 *
 * @param find      property lookup
 * @param receiver  receiver
 * @param desc      callsite descriptor
 *
 * @return resulting getter, or null if failed to create constant
 */
GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) {
    // Only use constant getter for fast scope access, because the receiver may change between invocations
    // for slow-scope and non-scope callsites.
    // Also return null for user accessor properties as they may have side effects.
    if (invalidatedForever.get() || !NashornCallSiteDescriptor.isFastScope(desc)
            || (GLOBAL_ONLY && !find.getOwner().isGlobal())
            || find.getProperty() instanceof UserAccessorProperty) {
        return null;
    }

    final boolean  isOptimistic = NashornCallSiteDescriptor.isOptimistic(desc);
    final int      programPoint = isOptimistic ? getProgramPoint(desc) : INVALID_PROGRAM_POINT;
    final Class<?> retType      = desc.getMethodType().returnType();
    final String   name         = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);

    synchronized (this) {
        final Access acc = getOrCreateSwitchPoint(name);

        log.fine("Starting to look up object value " + name);
        final Object c = find.getObjectValue();

        if (log.isEnabled()) {
            log.fine("Trying to link constant GETTER " + acc + " value = " + c);
        }

        if (acc.hasBeenInvalidated() || acc.guardFailed() || invalidatedForever.get()) {
            if (log.isEnabled()) {
                log.info("*** GET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation());
            }
            return null;
        }

        final MethodHandle cmh = constantGetter(c);

        MethodHandle mh;
        MethodHandle guard;

        if (isOptimistic) {
            if (JSType.getAccessorTypeIndex(cmh.type().returnType()) <= JSType.getAccessorTypeIndex(retType)) {
                //widen return type - this is pessimistic, so it will always work
                mh = MH.asType(cmh, cmh.type().changeReturnType(retType));
            } else {
                //immediately invalidate - we asked for a too wide constant as a narrower one
                mh = MH.dropArguments(MH.insertArguments(JSType.THROW_UNWARRANTED.methodHandle(), 0, c, programPoint), 0, Object.class);
            }
        } else {
            //pessimistic return type filter
            mh = Lookup.filterReturnType(cmh, retType);
        }

        if (find.getOwner().isGlobal()) {
            guard = null;
        } else {
            guard = MH.insertArguments(RECEIVER_GUARD, 0, acc, receiver);
        }

        if (log.isEnabled()) {
            log.info("Linked getter " + quote(name) + " as MethodHandle.constant() -> " + c + " " + acc.getSwitchPoint());
            mh = MethodHandleFactory.addDebugPrintout(log, Level.FINE, mh, "get const " + acc);
        }

        return new GuardedInvocation(mh, guard, acc.getSwitchPoint(), null);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:74,代码来源:GlobalConstants.java

示例11: initLoggers

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
private void initLoggers() {
    ((Loggable)MethodHandleFactory.getFunctionality()).initLogger(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:Context.java

示例12: findGetMethod

import jdk.nashorn.internal.lookup.MethodHandleFactory; //导入依赖的package包/类
/**
 * Try to turn a getter into a MethodHandle.constant, if possible
 *
 * @param find      property lookup
 * @param receiver  receiver
 * @param desc      callsite descriptor
 *
 * @return resulting getter, or null if failed to create constant
 */
GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) {
    // Only use constant getter for fast scope access, because the receiver may change between invocations
    // for slow-scope and non-scope callsites.
    // Also return null for user accessor properties as they may have side effects.
    if (invalidatedForever.get() || !NashornCallSiteDescriptor.isFastScope(desc)
            || (GLOBAL_ONLY && !find.getOwner().isGlobal())
            || find.getProperty() instanceof UserAccessorProperty) {
        return null;
    }

    final boolean  isOptimistic = NashornCallSiteDescriptor.isOptimistic(desc);
    final int      programPoint = isOptimistic ? getProgramPoint(desc) : INVALID_PROGRAM_POINT;
    final Class<?> retType      = desc.getMethodType().returnType();
    final String   name         = NashornCallSiteDescriptor.getOperand(desc);

    synchronized (this) {
        final Access acc = getOrCreateSwitchPoint(name);

        log.fine("Starting to look up object value " + name);
        final Object c = find.getObjectValue();

        if (log.isEnabled()) {
            log.fine("Trying to link constant GETTER " + acc + " value = " + c);
        }

        if (acc.hasBeenInvalidated() || acc.guardFailed() || invalidatedForever.get()) {
            if (log.isEnabled()) {
                log.info("*** GET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation());
            }
            return null;
        }

        final MethodHandle cmh = constantGetter(c);

        MethodHandle mh;
        MethodHandle guard;

        if (isOptimistic) {
            if (JSType.getAccessorTypeIndex(cmh.type().returnType()) <= JSType.getAccessorTypeIndex(retType)) {
                //widen return type - this is pessimistic, so it will always work
                mh = MH.asType(cmh, cmh.type().changeReturnType(retType));
            } else {
                //immediately invalidate - we asked for a too wide constant as a narrower one
                mh = MH.dropArguments(MH.insertArguments(JSType.THROW_UNWARRANTED.methodHandle(), 0, c, programPoint), 0, Object.class);
            }
        } else {
            //pessimistic return type filter
            mh = Lookup.filterReturnType(cmh, retType);
        }

        if (find.getOwner().isGlobal()) {
            guard = null;
        } else {
            guard = MH.insertArguments(RECEIVER_GUARD, 0, acc, receiver);
        }

        if (log.isEnabled()) {
            log.info("Linked getter " + quote(name) + " as MethodHandle.constant() -> " + c + " " + acc.getSwitchPoint());
            mh = MethodHandleFactory.addDebugPrintout(log, Level.FINE, mh, "get const " + acc);
        }

        return new GuardedInvocation(mh, guard, acc.getSwitchPoint(), null);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:74,代码来源:GlobalConstants.java


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