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


Java Handle类代码示例

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


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

示例1: visitInvokeDynamicInsn

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }

        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:AdviceAdapter.java

示例2: visitInvokeDynamicInsn

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    buf.setLength(0);
    buf.append(this.name).append(".visitInvokeDynamicInsn(");
    appendConstant(name);
    buf.append(", ");
    appendConstant(desc);
    buf.append(", ");
    appendConstant(bsm);
    buf.append(", new Object[]{");
    for (int i = 0; i < bsmArgs.length; ++i) {
        appendConstant(bsmArgs[i]);
        if (i != bsmArgs.length - 1) {
            buf.append(", ");
        }
    }
    buf.append("});\n");
    text.add(buf.toString());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:ASMifier.java

示例3: visitInvokeDynamicInsn

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    checkStartCode();
    checkEndCode();
    checkMethodIdentifier(version, name, "name");
    checkMethodDesc(desc);
    if (bsm.getTag() != Opcodes.H_INVOKESTATIC
            && bsm.getTag() != Opcodes.H_NEWINVOKESPECIAL) {
        throw new IllegalArgumentException("invalid handle tag "
                + bsm.getTag());
    }
    for (int i = 0; i < bsmArgs.length; i++) {
        checkLDCConstant(bsmArgs[i]);
    }
    super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    ++insnCount;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:CheckMethodAdapter.java

示例4: callSuper

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
private void callSuper(final MethodGenerator mi) {
    String superClass, superDesc;
    mi.loadThis();
    if (constructor == null) {
        // call ScriptObject.<init>
        superClass = SCRIPTOBJECT_TYPE;
        superDesc = (memberCount > 0) ? SCRIPTOBJECT_INIT_DESC : DEFAULT_INIT_DESC;
        loadMap(mi);
    } else {
        // call Function.<init>
        superClass = SCRIPTFUNCTIONIMPL_TYPE;
        superDesc = (memberCount > 0) ? SCRIPTFUNCTIONIMPL_INIT_DESC4 : SCRIPTFUNCTIONIMPL_INIT_DESC3;
        mi.loadLiteral(constructor.getName());
        mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc()));
        loadMap(mi);
        mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty
    }

    mi.invokeSpecial(superClass, INIT, superDesc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:ConstructorGenerator.java

示例5: memberInfoArray

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
void memberInfoArray(final String className, final List<MemberInfo> mis) {
    if (mis.isEmpty()) {
        pushNull();
        return;
    }

    int pos = 0;
    push(mis.size());
    newObjectArray(SPECIALIZATION_TYPE);
    for (final MemberInfo mi : mis) {
        dup();
        push(pos++);
        visitTypeInsn(NEW, SPECIALIZATION_TYPE);
        dup();
        visitLdcInsn(new Handle(H_INVOKESTATIC, className, mi.getJavaName(), mi.getJavaDesc()));
        final Type    linkLogicClass = mi.getLinkLogicClass();
        final boolean linkLogic      = !linkLogicIsEmpty(linkLogicClass);
        final String  ctor           = linkLogic ? SPECIALIZATION_INIT3 : SPECIALIZATION_INIT2;
        if (linkLogic) {
            visitLdcInsn(linkLogicClass);
        }
        visitInsn(mi.isOptimistic() ? ICONST_1 : ICONST_0);
        visitMethodInsn(INVOKESPECIAL, SPECIALIZATION_TYPE, INIT, ctor, false);
        arrayStore(TYPE_SPECIALIZATION);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:MethodGenerator.java

示例6: ldc

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public Type ldc(final MethodVisitor method, final Object c) {
    if (c == null) {
        method.visitInsn(ACONST_NULL);
    } else if (c instanceof Undefined) {
        return loadUndefined(method);
    } else if (c instanceof String) {
        method.visitLdcInsn(c);
        return STRING;
    } else if (c instanceof Handle) {
        method.visitLdcInsn(c);
        return Type.typeFor(MethodHandle.class);
    } else {
        throw new UnsupportedOperationException("implementation missing for class " + c.getClass() + " value=" + c);
    }

    return Type.OBJECT;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:ObjectType.java

示例7: generateBootstrapMethod

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
private Handle generateBootstrapMethod(Handle h) {
    String bootstrapName = "bootstrapMethod";
    MethodType bootstrapType = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class);

    MethodVisitor bmv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, bootstrapName, bootstrapType.toMethodDescriptorString(), null, null);
    bmv.visitCode();

    String constCallSite = "java/lang/invoke/ConstantCallSite";
    bmv.visitTypeInsn(NEW, constCallSite);
    bmv.visitInsn(DUP);

    bmv.visitLdcInsn(h);

    bmv.visitMethodInsn(INVOKESPECIAL, constCallSite, "<init>", "(Ljava/lang/invoke/MethodHandle;)V", false);
    bmv.visitInsn(ARETURN);

    bmv.visitMaxs(0,0);
    bmv.visitEnd();

    return new Handle(H_INVOKESTATIC, ownerClassName, bootstrapName, bootstrapType.toMethodDescriptorString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Method.java

示例8: getClassFile

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
static byte[] getClassFile(String suffix) {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    MethodVisitor mv;
    cw.visit(52, ACC_PUBLIC | ACC_SUPER, CLASS_NAME + suffix, null, "java/lang/Object", null);
    {
        mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, METHOD_NAME, TYPE.toMethodDescriptorString(), null, null);
        mv.visitCode();
        Handle bsm = new Handle(H_INVOKESTATIC,
                CallSiteDepContextTest.class.getName().replace(".", "/"),
                "bootstrap",
                bsmMH.type().toMethodDescriptorString());
        mv.visitInvokeDynamicInsn("methodName", TYPE.toMethodDescriptorString(), bsm);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
        mv.visitEnd();
    }
    cw.visitEnd();
    return cw.toByteArray();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:CallSiteDepContextTest.java

示例9: callSuper

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
private void callSuper(final MethodGenerator mi) {
    String superClass, superDesc;
    mi.loadThis();
    if (constructor == null) {
        // call ScriptObject.<init>
        superClass = SCRIPTOBJECT_TYPE;
        superDesc = (memberCount > 0) ? SCRIPTOBJECT_INIT_DESC : DEFAULT_INIT_DESC;
        loadMap(mi);
    } else {
        // call Function.<init>
        superClass = SCRIPTFUNCTION_TYPE;
        superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3;
        mi.loadLiteral(constructor.getName());
        mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc(), false));
        loadMap(mi);
        mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty
    }

    mi.invokeSpecial(superClass, INIT, superDesc);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ConstructorGenerator.java

示例10: callSuper

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void callSuper(final MethodGenerator mi) {
    String superClass, superDesc;
    mi.loadThis();
    if (constructor == null) {
        // call ScriptObject.<init>
        superClass = SCRIPTOBJECT_TYPE;
        superDesc = (memberCount > 0) ? SCRIPTOBJECT_INIT_DESC : DEFAULT_INIT_DESC;
        loadMap(mi);
    } else {
        // call Function.<init>
        superClass = SCRIPTFUNCTION_TYPE;
        superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3;
        mi.loadLiteral(constructor.getName());
        mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc()));
        loadMap(mi);
        mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty
    }

    mi.invokeSpecial(superClass, INIT, superDesc);
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:22,代码来源:ConstructorGenerator.java

示例11: callSuper

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
private void callSuper(final MethodGenerator mi) {
    String superClass, superDesc;
    mi.loadThis();
    if (constructor == null) {
        // call ScriptObject.<init>
        superClass = SCRIPTOBJECT_TYPE;
        superDesc = (memberCount > 0) ? SCRIPTOBJECT_INIT_DESC : DEFAULT_INIT_DESC;
        loadMap(mi);
    } else {
        // call Function.<init>
        superClass = SCRIPTFUNCTION_TYPE;
        superDesc = (memberCount > 0) ? SCRIPTFUNCTION_INIT_DESC4 : SCRIPTFUNCTION_INIT_DESC3;
        mi.loadLiteral(constructor.getName());
        mi.visitLdcInsn(new Handle(H_INVOKESTATIC, scriptClassInfo.getJavaName(), constructor.getJavaName(), constructor.getJavaDesc()));
        loadMap(mi);
        mi.memberInfoArray(scriptClassInfo.getJavaName(), specs); //pushes null if specs empty
    }

    mi.invokeSpecial(superClass, INIT, superDesc);
}
 
开发者ID:JetBrains,项目名称:jdk8u_nashorn,代码行数:21,代码来源:ConstructorGenerator.java

示例12: visitInvokeDynamicInsn

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    for (int i = 0; i < bsmArgs.length; i++) {
        bsmArgs[i] = remapper.mapValue(bsmArgs[i]);
    }
    super.visitInvokeDynamicInsn(
            remapper.mapInvokeDynamicMethodName(name, desc),
            remapper.mapMethodDesc(desc), (Handle) remapper.mapValue(bsm),
            bsmArgs);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:RemappingMethodAdapter.java

示例13: mapValue

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
public Object mapValue(Object value) {
    if (value instanceof Type) {
        return mapType((Type) value);
    }
    if (value instanceof Handle) {
        Handle h = (Handle) value;
        return new Handle(h.getTag(), mapType(h.getOwner()), mapMethodName(
                h.getOwner(), h.getName(), h.getDesc()),
                mapMethodDesc(h.getDesc()));
    }
    return value;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:Remapper.java

示例14: visitInvokeDynamicInsn

import jdk.internal.org.objectweb.asm.Handle; //导入依赖的package包/类
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm,
        Object... bsmArgs) {
    minSize += 5;
    maxSize += 5;
    if (mv != null) {
        mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:CodeSizeEvaluator.java


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