當前位置: 首頁>>代碼示例>>Java>>正文


Java Opcodes.INVOKEINTERFACE屬性代碼示例

本文整理匯總了Java中org.objectweb.asm.Opcodes.INVOKEINTERFACE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Opcodes.INVOKEINTERFACE屬性的具體用法?Java Opcodes.INVOKEINTERFACE怎麽用?Java Opcodes.INVOKEINTERFACE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.objectweb.asm.Opcodes的用法示例。


在下文中一共展示了Opcodes.INVOKEINTERFACE屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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:acmerli,項目名稱:fastAOP,代碼行數:19,代碼來源:InstructionAdapter.java

示例2: visitMethodInsn

@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
  DexType ownerType = application.getTypeFromName(owner);
  DexMethod method = application.getMethod(ownerType, name, desc);
  switch (opcode) {
    case Opcodes.INVOKEVIRTUAL:
      registry.registerInvokeVirtual(method);
      break;
    case Opcodes.INVOKESTATIC:
      registry.registerInvokeStatic(method);
      break;
    case Opcodes.INVOKEINTERFACE:
      registry.registerInvokeInterface(method);
      break;
    case Opcodes.INVOKESPECIAL:
      if (name.equals(Constants.INSTANCE_INITIALIZER_NAME) || ownerType == clazz) {
        registry.registerInvokeDirect(method);
      } else {
        registry.registerInvokeSuper(method);
      }
      break;
    default:
      throw new Unreachable("Unexpected opcode " + opcode);
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:25,代碼來源:JarRegisterEffectsVisitor.java

示例3: invokeType

private Invoke.Type invokeType(MethodInsnNode method) {
  switch (method.getOpcode()) {
    case Opcodes.INVOKEVIRTUAL:
      if (isCallToPolymorphicSignatureMethod(method)) {
        return Invoke.Type.POLYMORPHIC;
      }
      return Invoke.Type.VIRTUAL;
    case Opcodes.INVOKESTATIC:
      return Invoke.Type.STATIC;
    case Opcodes.INVOKEINTERFACE:
      return Invoke.Type.INTERFACE;
    case Opcodes.INVOKESPECIAL: {
      DexType owner = application.getTypeFromName(method.owner);
      if (owner == clazz || method.name.equals(Constants.INSTANCE_INITIALIZER_NAME)) {
        return Invoke.Type.DIRECT;
      } else {
        return Invoke.Type.SUPER;
      }
    }
    default:
      throw new Unreachable("Unexpected MethodInsnNode opcode: " + method.getOpcode());
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:23,代碼來源:JarSourceCode.java

示例4: visit

/**
 * Output call instructions, outputing the correct opcode for the type of
 * call.
 *
 * @param instruction Call instruction.
 * @return            <code>null</code>
 */
@Override
public Void visit(Call instruction) {
  Method    m = instruction.getMethod();
  ClassNode c = m.getOwner();
  
  int opcode;

  switch(instruction.getSort()) {
    case INTERFACE: opcode = Opcodes.INVOKEINTERFACE; break;
    case VIRTUAL:   opcode = Opcodes.INVOKEVIRTUAL;   break;
    case SPECIAL:   opcode = Opcodes.INVOKESPECIAL;   break;
    case STATIC:    opcode = Opcodes.INVOKESTATIC;    break;
    default:        throw new RuntimeException("Unknown call type");
  }

  mv.visitMethodInsn(opcode, c.getName(), m.getName(), m.getDescriptor());
  
  return null;
}
 
開發者ID:adnanmitf09,項目名稱:Rubus,代碼行數:26,代碼來源:InstructionExporter.java

示例5: 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");
    }
    if (opcode == Opcodes.INVOKESPECIAL && itf
            && (version & 0xFFFF) < Opcodes.V1_8) {
        throw new IllegalArgumentException(
                "INVOKESPECIAL can't be used with interfaces prior to Java 8");
    }

    // 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:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:33,代碼來源:CheckMethodAdapter.java

示例6: 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:acmerli,項目名稱:fastAOP,代碼行數:59,代碼來源:MethodNode.java

示例7: canThrow

private boolean canThrow(AbstractInsnNode insn) {
  switch (insn.getOpcode()) {
    case Opcodes.AALOAD:
    case Opcodes.AASTORE:
    case Opcodes.ANEWARRAY:
      // ARETURN does not throw in its dex image.
    case Opcodes.ARRAYLENGTH:
    case Opcodes.ATHROW:
    case Opcodes.BALOAD:
    case Opcodes.BASTORE:
    case Opcodes.CALOAD:
    case Opcodes.CASTORE:
    case Opcodes.CHECKCAST:
    case Opcodes.DALOAD:
    case Opcodes.DASTORE:
      // DRETURN does not throw in its dex image.
    case Opcodes.FALOAD:
    case Opcodes.FASTORE:
      // FRETURN does not throw in its dex image.
    case Opcodes.GETFIELD:
    case Opcodes.GETSTATIC:
    case Opcodes.IALOAD:
    case Opcodes.IASTORE:
    case Opcodes.IDIV:
    case Opcodes.INSTANCEOF:
    case Opcodes.INVOKEDYNAMIC:
    case Opcodes.INVOKEINTERFACE:
    case Opcodes.INVOKESPECIAL:
    case Opcodes.INVOKESTATIC:
    case Opcodes.INVOKEVIRTUAL:
    case Opcodes.IREM:
      // IRETURN does not throw in its dex image.
    case Opcodes.LALOAD:
    case Opcodes.LASTORE:
    case Opcodes.LDIV:
    case Opcodes.LREM:
      // LRETURN does not throw in its dex image.
    case Opcodes.MONITORENTER:
    case Opcodes.MONITOREXIT:
    case Opcodes.MULTIANEWARRAY:
    case Opcodes.NEW:
    case Opcodes.NEWARRAY:
    case Opcodes.PUTFIELD:
    case Opcodes.PUTSTATIC:
      // RETURN does not throw in its dex image.
    case Opcodes.SALOAD:
    case Opcodes.SASTORE:
      return true;
    case Opcodes.LDC: {
      // const-class and const-string* may throw in dex.
      LdcInsnNode ldc = (LdcInsnNode) insn;
      return ldc.cst instanceof String || ldc.cst instanceof Type;
    }
    default:
      return false;
  }
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:57,代碼來源:JarSourceCode.java

示例8: create

/**
 * Create an opcode from the current open card. If there's an input
 * exception no node is returned.
 *
 * @return The opcode created.
 */
public AbstractInsnNode create() {
	try {
		switch (nameToType.get(currentType)) {
		case AbstractInsnNode.INSN:
			return new InsnNode(getOpcode());
		case AbstractInsnNode.INT_INSN:
			return new IntInsnNode(getOpcode(), getInt("value"));
		case AbstractInsnNode.VAR_INSN:
			return new VarInsnNode(getOpcode(), getInt("var"));
		case AbstractInsnNode.TYPE_INSN:
			return new TypeInsnNode(getOpcode(), getString("value"));
		case AbstractInsnNode.FIELD_INSN:
			return new FieldInsnNode(getOpcode(), getString("owner"), getString("name"), getString("desc"));
		case AbstractInsnNode.METHOD_INSN:
			return new MethodInsnNode(getOpcode(), getString("owner"), getString("name"), getString("desc"),
					getOpcode() == Opcodes.INVOKEINTERFACE);
		case AbstractInsnNode.INVOKE_DYNAMIC_INSN:
			break;
		case AbstractInsnNode.LABEL:
			return new LabelNode();
		case AbstractInsnNode.LDC_INSN:
			String ldcStr = get("value");
			Object cst = null;
			switch (comboType.getSelectedItem().toString()) {
			case "String":
				cst = ldcStr;
				break;
			case "int":
				cst = Integer.parseInt(ldcStr);
				break;
			case "long":
				cst = Long.parseLong(ldcStr);
				break;
			case "float":
				cst = Float.parseFloat(ldcStr);
				break;
			case "double":
				cst = Double.parseDouble(ldcStr);
				break;
			case "Type":
				cst = Type.getType(ldcStr);
				break;
			}
			return new LdcInsnNode(cst);
		case AbstractInsnNode.IINC_INSN:
			return new IincInsnNode(getInt("var"), getInt("inc"));
		case AbstractInsnNode.LINE:
			return new LineNumberNode(getInt("value"), new LabelNode());
		case AbstractInsnNode.MULTIANEWARRAY_INSN:
			return new MultiANewArrayInsnNode(getString("desc"), getInt("dims"));
		case AbstractInsnNode.JUMP_INSN:
			return new JumpInsnNode(getOpcode(), getLabel("value"));
		case AbstractInsnNode.TABLESWITCH_INSN:
			break;
		case AbstractInsnNode.LOOKUPSWITCH_INSN:
			break;
		case AbstractInsnNode.FRAME:
			break;
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:Col-E,項目名稱:Recaf,代碼行數:70,代碼來源:OpcodeCreationBox.java

示例9: visitMethodInsn

/**
 * Method instruction.
 * See {@link 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 org.objectweb.asm.Type#getInternalName() getInternalName}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link org.objectweb.asm.Type Type}).
 */
@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:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:26,代碼來源:Printer.java

示例10: visitMethodInsn

/**
 * Method instruction.
 * See {@link 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 org.objectweb.asm.Type#getInternalName() getInternalName}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link 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:acmerli,項目名稱:fastAOP,代碼行數:30,代碼來源:Printer.java

示例11: 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 org.objectweb.asm.Type#getInternalName()
 *            getInternalName}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link 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:ItzSomebody,項目名稱:Spigot-Nonce-ID-Finder,代碼行數:21,代碼來源:MethodInsnNode.java


注:本文中的org.objectweb.asm.Opcodes.INVOKEINTERFACE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。