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


Java InsnList.toArray方法代碼示例

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


在下文中一共展示了InsnList.toArray方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNode

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
protected AbstractInsnNode getNode(InsnList nodes, Predicate<AbstractInsnNode> validator) {
    for (AbstractInsnNode node : nodes.toArray()) {
        if (validator.test(node)) {
            return node;
        }
    }
    return null;
}
 
開發者ID:gegy1000,項目名稱:BlockSystems,代碼行數:9,代碼來源:Transformer.java

示例2: getNodeLast

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
protected AbstractInsnNode getNodeLast(InsnList nodes, Predicate<AbstractInsnNode> validator) {
    AbstractInsnNode last = null;
    for (AbstractInsnNode node : nodes.toArray()) {
        if (validator.test(node)) {
            last = node;
        }
    }
    return last;
}
 
開發者ID:gegy1000,項目名稱:BlockSystems,代碼行數:10,代碼來源:Transformer.java

示例3: ListContains

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
public static boolean ListContains(InsnList il, String s) {
	for (AbstractInsnNode ain : il.toArray())
		if (InstructionContains(ain, s))
			return true;

	return false;
}
 
開發者ID:8BitPlus,項目名稱:BitPlus,代碼行數:8,代碼來源:LdcContains.java

示例4: fixMethodBody

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * 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,代碼行數:65,代碼來源:MockableJarGenerator.java

示例5: fixMethodBody

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * 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;

    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:jskierbi,項目名稱:intellij-ce-playground,代碼行數:56,代碼來源:MockableJarGenerator.java


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