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


Java Opcodes.INVOKESPECIAL屬性代碼示例

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


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

public static void setSuper(ClassNode node, String superClass) {
    String replacedSuper = "";
    if (node.superName != "") {
        replacedSuper = node.superName;
    }
    if (replacedSuper != "") {
        ListIterator<?> mli = node.methods.listIterator();
        while (mli.hasNext()) {
            MethodNode      mn  = (MethodNode) mli.next();
            ListIterator<?> ili = mn.instructions.iterator();
            while (ili.hasNext()) {
                AbstractInsnNode ain = (AbstractInsnNode) ili.next();
                if (ain.getOpcode() == Opcodes.INVOKESPECIAL) {
                    MethodInsnNode min = (MethodInsnNode) ain;
                    if (min.owner.equals(replacedSuper)) {
                        min.owner = superClass;
                    }
                }
            }
        }
    }
    node.superName = superClass;
}
 
開發者ID:Parabot,項目名稱:Parabot-317-API-Minified-OS-Scape,代碼行數:23,代碼來源:ArchiveClassLoader.java

示例6: addWhereAmI

private void addWhereAmI() {
	// 0: new #2; //class java/lang/Exception
	// 3: dup
	// 4: invokespecial #3; //Method java/lang/Exception."<init>":()V
	// 7: invokevirtual #4; //Method
	// java/lang/Exception.printStackTrace:()V
	// 10: return
	// super.visitTypeInsn(Opcodes.NEW, type);
	String exClass = Type.getInternalName(Exception.class);
	super.visitTypeInsn(Opcodes.NEW, exClass);
	super.visitInsn(Opcodes.DUP);
	super.visitMethodInsn(Opcodes.INVOKESPECIAL, exClass, "<init>",
			"()V");
	super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, exClass,
			"printStackTrace", "()V");
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:16,代碼來源:AllocateInstrument.java

示例7: transformInvocations

private void transformInvocations() {
    for (Iterator<AbstractInsnNode> it = (Iterator<AbstractInsnNode>) resultNode.instructions.iterator(); it.hasNext(); ) {
        AbstractInsnNode insn = it.next();

        if (insn instanceof MethodInsnNode) {
            MethodInsnNode methodInsn = (MethodInsnNode) insn;

            if (methodInsn.getOpcode() == Opcodes.INVOKESPECIAL && methodInsn.owner.equals(this.owner))
                methodInsn.owner = this.superClass;
            else if (methodInsn.owner.equals(transformer)) {
                methodInsn.owner = this.owner;
            }

            if (methodInsn.name.endsWith("_INJECTED")) {
                methodInsn.name = methodInsn.name.substring(0, methodInsn.name.length() - 9);
            }

        }

        if (insn instanceof FieldInsnNode) {
            FieldInsnNode fieldInsn = (FieldInsnNode) insn;

            if (fieldInsn.owner.equals(transformer))
                fieldInsn.owner = this.owner;
        }

    }
}
 
開發者ID:Yamakaja,項目名稱:RuntimeTransformer,代碼行數:28,代碼來源:MethodJob.java

示例8: replaceSuperCtorCalls

/**
 * Replaces class references in super constructor invocations.
 * Must not replace references in this() constructor invocations.
 * 
 * @param theClass the class being patched
 * @param extenderClass the injected superclass
 * @param mn method to process
 */
private static void replaceSuperCtorCalls(final ClassNode theClass, final ClassNode extenderClass, MethodNode mn) {
    for (Iterator it = mn.instructions.iterator(); it.hasNext(); ) {
        AbstractInsnNode aIns = (AbstractInsnNode)it.next();
        if (aIns.getOpcode() == Opcodes.INVOKESPECIAL) {
            MethodInsnNode mins = (MethodInsnNode)aIns;
            if (CONSTRUCTOR_NAME.equals(mins.name) && mins.owner.equals(extenderClass.superName)) {
                // replace with the extender class name
                mins.owner = extenderClass.name;
            }
            break;
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:Asm.java

示例9: doVisitMethodInsn

private void doVisitMethodInsn(int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    if (mv != null) {
        mv.visitMethodInsn(opcode, owner, name, desc, itf);
    }
    if (this.locals == null) {
        labels = null;
        return;
    }
    pop(desc);
    if (opcode != Opcodes.INVOKESTATIC) {
        Object t = pop();
        if (opcode == Opcodes.INVOKESPECIAL && name.charAt(0) == '<') {
            Object u;
            if (t == Opcodes.UNINITIALIZED_THIS) {
                u = this.owner;
            } else {
                u = uninitializedTypes.get(t);
            }
            for (int i = 0; i < locals.size(); ++i) {
                if (locals.get(i) == t) {
                    locals.set(i, u);
                }
            }
            for (int i = 0; i < stack.size(); ++i) {
                if (stack.get(i) == t) {
                    stack.set(i, u);
                }
            }
        }
    }
    pushDesc(desc);
    labels = null;
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:34,代碼來源:AnalyzerAdapter.java

示例10: 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

示例11: 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

示例12: fixMethodBody

/**
 * Rewrites the method bytecode to remove the "Stub!" exception.
 */
private void fixMethodBody(MethodNode methodNode, ClassNode classNode) {
    if ((methodNode.access & Opcodes.ACC_NATIVE) != 0
            || (methodNode.access & Opcodes.ACC_ABSTRACT) != 0) {
        // Abstract and native method don't have bodies to rewrite.
        return;
    }
    
    if ((classNode.access & Opcodes.ACC_ENUM) != 0 && ENUM_METHODS.contains(methodNode.name)) {
        // Don't break enum classes.
        return;
    }
    
    Type returnType = Type.getReturnType(methodNode.desc);
    InsnList instructions = methodNode.instructions;
    List localVariables = methodNode.localVariables;
    List tryCatchBlocks = methodNode.tryCatchBlocks;

    if (localVariables != null && !localVariables.isEmpty()) {
        localVariables.clear();
    }
    if (tryCatchBlocks != null && !tryCatchBlocks.isEmpty()) {
        tryCatchBlocks.clear();
    }
    
    if (methodNode.name.equals(CONSTRUCTOR)) {
        // Keep the call to parent constructor, delete the exception after that.
        
        boolean deadCode = false;
        for (AbstractInsnNode instruction : instructions.toArray()) {
            if (!deadCode) {
                if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
                    instructions.insert(instruction, new InsnNode(Opcodes.RETURN));
                    // Start removing all following instructions.
                    deadCode = true;
                }
            } else {
                instructions.remove(instruction);
            }
        }
    } else {
        instructions.clear();
        
        if (returnDefaultValues || methodNode.name.equals(CLASS_CONSTRUCTOR)) {
            if (INTEGER_LIKE_TYPES.contains(returnType)) {
                instructions.add(new InsnNode(Opcodes.ICONST_0));
            } else if (returnType.equals(Type.LONG_TYPE)) {
                instructions.add(new InsnNode(Opcodes.LCONST_0));
            } else if (returnType.equals(Type.FLOAT_TYPE)) {
                instructions.add(new InsnNode(Opcodes.FCONST_0));
            } else if (returnType.equals(Type.DOUBLE_TYPE)) {
                instructions.add(new InsnNode(Opcodes.DCONST_0));
            } else {
                instructions.add(new InsnNode(Opcodes.ACONST_NULL));
            }
            
            instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN)));
        } else {
            instructions.insert(throwExceptionsList(methodNode, classNode));
        }
    }
}
 
開發者ID:codezjx,項目名稱:MockableJarGenerator,代碼行數:64,代碼來源:MockableJarGenerator.java


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