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


Java Opcodes.INVOKEINTERFACE属性代码示例

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


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

示例1: doVisitMethodInsn

private void doVisitMethodInsn(int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    switch (opcode) {
    case Opcodes.INVOKESPECIAL:
        invokespecial(owner, name, desc, itf);
        break;
    case Opcodes.INVOKEVIRTUAL:
        invokevirtual(owner, name, desc, itf);
        break;
    case Opcodes.INVOKESTATIC:
        invokestatic(owner, name, desc, itf);
        break;
    case Opcodes.INVOKEINTERFACE:
        invokeinterface(owner, name, desc);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:InstructionAdapter.java

示例2: doVisitMethodInsn

private void doVisitMethodInsn(int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    checkStartCode();
    checkEndCode();
    checkOpcode(opcode, 5);
    if (opcode != Opcodes.INVOKESPECIAL || !"<init>".equals(name)) {
        checkMethodIdentifier(version, name, "name");
    }
    checkInternalName(owner, "owner");
    checkMethodDesc(desc);
    if (opcode == Opcodes.INVOKEVIRTUAL && itf) {
        throw new IllegalArgumentException(
                "INVOKEVIRTUAL can't be used with interfaces");
    }
    if (opcode == Opcodes.INVOKEINTERFACE && !itf) {
        throw new IllegalArgumentException(
                "INVOKEINTERFACE can't be used with classes");
    }
    // Calling super.visitMethodInsn requires to call the correct version
    // depending on this.api (otherwise infinite loops can occur). To
    // simplify and to make it easier to automatically remove the backward
    // compatibility code, we inline the code of the overridden method here.
    if (mv != null) {
        mv.visitMethodInsn(opcode, owner, name, desc, itf);
    }
    ++insnCount;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:CheckMethodAdapter.java

示例3: visitMethodInsn

/**
 * Method instruction. See
 * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMethodInsn}.
 */
@Deprecated
public void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc) {
    if (api >= Opcodes.ASM5) {
        boolean itf = opcode == Opcodes.INVOKEINTERFACE;
        visitMethodInsn(opcode, owner, name, desc, itf);
        return;
    }
    throw new RuntimeException("Must be overriden");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:Printer.java

示例4: visitMethodInsn

/**
 * Method instruction. See
 * {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMethodInsn}.
 */
public void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    if (api < Opcodes.ASM5) {
        if (itf != (opcode == Opcodes.INVOKEINTERFACE)) {
            throw new IllegalArgumentException(
                    "INVOKESPECIAL/STATIC on interfaces require ASM 5");
        }
        visitMethodInsn(opcode, owner, name, desc);
        return;
    }
    throw new RuntimeException("Must be overriden");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:Printer.java

示例5: getInvokeInstruction

private static int getInvokeInstruction(SelectionResolutionTestCase.InvokeInstruction instr) {
    switch (instr) {
        case INVOKESTATIC:
            return Opcodes.INVOKESTATIC;
        case INVOKESPECIAL:
            return Opcodes.INVOKESPECIAL;
        case INVOKEINTERFACE:
            return Opcodes.INVOKEINTERFACE;
        case INVOKEVIRTUAL:
            return Opcodes.INVOKEVIRTUAL;
        default:
            throw new AssertionError(instr.name());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TestBuilder.java

示例6: visit

@Override
public byte[] visit(Function node) {
    FunctionInfo info = node.getValue();
    boolean needInstance = !info.isStatic() && !info.isConstructor();
    if (needInstance) {
        node.getChild(0).accept(this); // placing instance on stack
    }
    // call itself with specific invoke*
    String signature = info.argTypes.stream()
            .skip(!needInstance ? 0 : 1)
            .map(vi -> new String(vi.type.accept(this)))
            .collect(Collectors.joining("", "(", ")"))
            + (info.isConstructor() ? "V" : new String(node.getResultType().accept(this)));
    int invokeCode = Opcodes.INVOKEVIRTUAL;
    if (info.isStatic()) {
        invokeCode = Opcodes.INVOKESTATIC;
    } else if (info.isConstructor() || info.isPrivate()) {
        // TODO : superclass method invocation?
        invokeCode = Opcodes.INVOKESPECIAL;
    } else {
        if (info.owner.isInterface()) {
            invokeCode = Opcodes.INVOKEINTERFACE;
        }
    }
    if (info.isConstructor()) {
        currentMV.visitTypeInsn(Opcodes.NEW, asInternalName(info.owner.getName()));
        currentMV.visitInsn(Opcodes.DUP);
    }
    // calculating parameters
    node.getChildren().stream()
            .skip(!needInstance ? 0 : 1)
            .forEachOrdered(c -> c.accept(this));
    currentMV.visitMethodInsn(invokeCode, asInternalName(info.owner.getName()),
            info.isConstructor() ? "<init>" : info.name, signature,
            invokeCode == Opcodes.INVOKEINTERFACE);
    return EMPTY_BYTE_ARRAY;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:ByteCodeVisitor.java

示例7: refKindOpcode

int refKindOpcode(byte refKind) {
    switch (refKind) {
    case REF_invokeVirtual:      return Opcodes.INVOKEVIRTUAL;
    case REF_invokeStatic:       return Opcodes.INVOKESTATIC;
    case REF_invokeSpecial:      return Opcodes.INVOKESPECIAL;
    case REF_invokeInterface:    return Opcodes.INVOKEINTERFACE;
    case REF_getField:           return Opcodes.GETFIELD;
    case REF_putField:           return Opcodes.PUTFIELD;
    case REF_getStatic:          return Opcodes.GETSTATIC;
    case REF_putStatic:          return Opcodes.PUTSTATIC;
    }
    throw new InternalError("refKind="+refKind);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:InvokerBytecodeGenerator.java

示例8: check

/**
 * Checks that this method node is compatible with the given ASM API
 * version. This methods checks that this node, and all its nodes
 * recursively, do not contain elements that were introduced in more recent
 * versions of the ASM API than the given version.
 *
 * @param api
 *            an ASM API version. Must be one of {@link Opcodes#ASM4} or
 *            {@link Opcodes#ASM5}.
 */
public void check(final int api) {
    if (api == Opcodes.ASM4) {
        if (visibleTypeAnnotations != null
                && visibleTypeAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        if (invisibleTypeAnnotations != null
                && invisibleTypeAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        int n = tryCatchBlocks == null ? 0 : tryCatchBlocks.size();
        for (int i = 0; i < n; ++i) {
            TryCatchBlockNode tcb = tryCatchBlocks.get(i);
            if (tcb.visibleTypeAnnotations != null
                    && tcb.visibleTypeAnnotations.size() > 0) {
                throw new RuntimeException();
            }
            if (tcb.invisibleTypeAnnotations != null
                    && tcb.invisibleTypeAnnotations.size() > 0) {
                throw new RuntimeException();
            }
        }
        for (int i = 0; i < instructions.size(); ++i) {
            AbstractInsnNode insn = instructions.get(i);
            if (insn.visibleTypeAnnotations != null
                    && insn.visibleTypeAnnotations.size() > 0) {
                throw new RuntimeException();
            }
            if (insn.invisibleTypeAnnotations != null
                    && insn.invisibleTypeAnnotations.size() > 0) {
                throw new RuntimeException();
            }
            if (insn instanceof MethodInsnNode) {
                boolean itf = ((MethodInsnNode) insn).itf;
                if (itf != (insn.opcode == Opcodes.INVOKEINTERFACE)) {
                    throw new RuntimeException();
                }
            }
        }
        if (visibleLocalVariableAnnotations != null
                && visibleLocalVariableAnnotations.size() > 0) {
            throw new RuntimeException();
        }
        if (invisibleLocalVariableAnnotations != null
                && invisibleLocalVariableAnnotations.size() > 0) {
            throw new RuntimeException();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:MethodNode.java

示例9: visitMethodInsn

/**
 * Method instruction.
 * See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitMethodInsn}.
 *
 * @param opcode
 *            the opcode of the type instruction to be visited. This opcode
 *            is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
 *            INVOKEINTERFACE.
 * @param owner
 *            the internal name of the method's owner class (see
 *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName() getInternalName}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type Type}).
 * @param itf
 *            if the method's owner class is an interface.
 */
public void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    if (api < Opcodes.ASM5) {
        if (itf != (opcode == Opcodes.INVOKEINTERFACE)) {
            throw new IllegalArgumentException(
                    "INVOKESPECIAL/STATIC on interfaces require ASM 5");
        }
        visitMethodInsn(opcode, owner, name, desc);
        return;
    }
    throw new RuntimeException("Must be overriden");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:Printer.java

示例10: MethodInsnNode

/**
 * Constructs a new {@link MethodInsnNode}.
 *
 * @param opcode
 *            the opcode of the type instruction to be constructed. This
 *            opcode must be INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
 *            INVOKEINTERFACE.
 * @param owner
 *            the internal name of the method's owner class (see
 *            {@link jdk.internal.org.objectweb.asm.Type#getInternalName()
 *            getInternalName}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link jdk.internal.org.objectweb.asm.Type}).
 */
@Deprecated
public MethodInsnNode(final int opcode, final String owner,
        final String name, final String desc) {
    this(opcode, owner, name, desc, opcode == Opcodes.INVOKEINTERFACE);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:MethodInsnNode.java


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