本文整理汇总了Java中org.objectweb.asm.tree.AbstractInsnNode.METHOD_INSN属性的典型用法代码示例。如果您正苦于以下问题:Java AbstractInsnNode.METHOD_INSN属性的具体用法?Java AbstractInsnNode.METHOD_INSN怎么用?Java AbstractInsnNode.METHOD_INSN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.objectweb.asm.tree.AbstractInsnNode
的用法示例。
在下文中一共展示了AbstractInsnNode.METHOD_INSN属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformCode
public byte[] transformCode(byte[] b1, String className) throws IOException {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
ClassReader cr = new ClassReader(b1);
ClassNode classNode = new ClassNode();
Map<String, Boolean> methodInstructionTypeMap = new HashMap<>();
cr.accept(classNode, 0);
final List<MethodNode> methods = classNode.methods;
for (MethodNode m : methods) {
InsnList inList = m.instructions;
boolean isMethodInvoke = false;
for (int i = 0; i < inList.size(); i++) {
if (inList.get(i).getType() == AbstractInsnNode.METHOD_INSN) {
isMethodInvoke = true;
}
}
methodInstructionTypeMap.put(m.name + m.desc, isMethodInvoke);
}
InsertMethodBodyAdapter insertMethodBodyAdapter = new InsertMethodBodyAdapter(cw, className, methodInstructionTypeMap);
cr.accept(insertMethodBodyAdapter, ClassReader.EXPAND_FRAMES);
return cw.toByteArray();
}
示例2: populateClassGraph
public void populateClassGraph() {
String className = Type.getObjectType(classNode.name).getClassName();
logger.debug("Creating graph for class {}" , className);
for (MethodNode methodNode : classNode.methods) {
String methodName = methodNode.name;
MethodGraph caller = new MethodGraph(className, methodName);
InsnList instructions = methodNode.instructions;
for (int i = 0; i < instructions.size(); i++) {
AbstractInsnNode insnNode = instructions.get(i);
if (insnNode.getType() == AbstractInsnNode.METHOD_INSN) {
MethodInsnNode methodInsnNode = (MethodInsnNode)insnNode;
String calledOwner = Type.getObjectType(methodInsnNode.owner).getClassName();
String calledName = methodInsnNode.name;
MethodGraph called = new MethodGraph(calledOwner, calledName);
Call call = new Call(caller, called);
if (!called.getOwner().equals("java.lang.Object") && !called.getName().equals("<init>")) {
logger.trace("Adding call graph: {}", call.toString());
GraphHolder.addCallGraph(call);
}
}
}
}
}
示例3: process
@Override
public void process() {
for (MethodNode methodNode : getClassNode().methods) {
InsnList instructions = methodNode.instructions;
for (int i = 0; i < instructions.size(); i++) {
AbstractInsnNode insnNode = instructions.get(i);
if (insnNode.getType() == AbstractInsnNode.METHOD_INSN) {
MethodInsnNode methodInsnNode = (MethodInsnNode)insnNode;
processMethodInsnNode(methodNode, methodInsnNode);
}
}
}
}
示例4: updateState
private void updateState(AbstractInsnNode insn) {
switch (insn.getType()) {
case AbstractInsnNode.INSN:
updateState((InsnNode) insn);
break;
case AbstractInsnNode.INT_INSN:
updateState((IntInsnNode) insn);
break;
case AbstractInsnNode.VAR_INSN:
updateState((VarInsnNode) insn);
break;
case AbstractInsnNode.TYPE_INSN:
updateState((TypeInsnNode) insn);
break;
case AbstractInsnNode.FIELD_INSN:
updateState((FieldInsnNode) insn);
break;
case AbstractInsnNode.METHOD_INSN:
updateState((MethodInsnNode) insn);
break;
case AbstractInsnNode.INVOKE_DYNAMIC_INSN:
updateState((InvokeDynamicInsnNode) insn);
break;
case AbstractInsnNode.JUMP_INSN:
updateState((JumpInsnNode) insn);
break;
case AbstractInsnNode.LABEL:
updateState((LabelNode) insn);
break;
case AbstractInsnNode.LDC_INSN:
updateState((LdcInsnNode) insn);
break;
case AbstractInsnNode.IINC_INSN:
updateState((IincInsnNode) insn);
break;
case AbstractInsnNode.TABLESWITCH_INSN:
updateState((TableSwitchInsnNode) insn);
break;
case AbstractInsnNode.LOOKUPSWITCH_INSN:
updateState((LookupSwitchInsnNode) insn);
break;
case AbstractInsnNode.MULTIANEWARRAY_INSN:
updateState((MultiANewArrayInsnNode) insn);
break;
case AbstractInsnNode.LINE:
updateState((LineNumberNode) insn);
break;
default:
throw new Unreachable("Unexpected instruction " + insn);
}
}
示例5: build
private void build(AbstractInsnNode insn, IRBuilder builder) {
switch (insn.getType()) {
case AbstractInsnNode.INSN:
build((InsnNode) insn, builder);
break;
case AbstractInsnNode.INT_INSN:
build((IntInsnNode) insn, builder);
break;
case AbstractInsnNode.VAR_INSN:
build((VarInsnNode) insn, builder);
break;
case AbstractInsnNode.TYPE_INSN:
build((TypeInsnNode) insn, builder);
break;
case AbstractInsnNode.FIELD_INSN:
build((FieldInsnNode) insn, builder);
break;
case AbstractInsnNode.METHOD_INSN:
build((MethodInsnNode) insn, builder);
break;
case AbstractInsnNode.INVOKE_DYNAMIC_INSN:
build((InvokeDynamicInsnNode) insn, builder);
break;
case AbstractInsnNode.JUMP_INSN:
build((JumpInsnNode) insn, builder);
break;
case AbstractInsnNode.LABEL:
build((LabelNode) insn, builder);
break;
case AbstractInsnNode.LDC_INSN:
build((LdcInsnNode) insn, builder);
break;
case AbstractInsnNode.IINC_INSN:
build((IincInsnNode) insn, builder);
break;
case AbstractInsnNode.TABLESWITCH_INSN:
build((TableSwitchInsnNode) insn, builder);
break;
case AbstractInsnNode.LOOKUPSWITCH_INSN:
build((LookupSwitchInsnNode) insn, builder);
break;
case AbstractInsnNode.MULTIANEWARRAY_INSN:
build((MultiANewArrayInsnNode) insn, builder);
break;
case AbstractInsnNode.LINE:
build((LineNumberNode) insn, builder);
break;
default:
throw new Unreachable("Unexpected instruction " + insn);
}
}
示例6: populate
private void populate() {
switch (opcode.getType()) {
case AbstractInsnNode.INSN:
populate(OpcodeUtil.getInsnSubset(OpcodeUtil.opcodeToName(opcode.getOpcode())));
break;
case AbstractInsnNode.INT_INSN:
populate(OpcodeUtil.OPS_INT);
break;
case AbstractInsnNode.VAR_INSN:
populate(OpcodeUtil.OPS_VAR);
break;
case AbstractInsnNode.TYPE_INSN:
populate(OpcodeUtil.OPS_TYPE);
break;
case AbstractInsnNode.FIELD_INSN:
populate(OpcodeUtil.OPS_FIELD);
break;
case AbstractInsnNode.METHOD_INSN:
populate(OpcodeUtil.OPS_METHOD);
break;
case AbstractInsnNode.INVOKE_DYNAMIC_INSN:
populate(OpcodeUtil.OPS_INDY_METHOD);
break;
case AbstractInsnNode.JUMP_INSN:
populate(OpcodeUtil.OPS_JUMP);
break;
case AbstractInsnNode.LDC_INSN:
populate(OpcodeUtil.OPS_LDC);
break;
case AbstractInsnNode.IINC_INSN:
populate(OpcodeUtil.OPS_IINC);
break;
case AbstractInsnNode.TABLESWITCH_INSN:
populate(OpcodeUtil.OPS_TABLESWITCH);
break;
case AbstractInsnNode.LOOKUPSWITCH_INSN:
populate(OpcodeUtil.OPS_LOOKUPSWITCH);
break;
case AbstractInsnNode.MULTIANEWARRAY_INSN:
populate(OpcodeUtil.OPS_MULTIANEWARRAY);
break;
case AbstractInsnNode.LABEL:
case AbstractInsnNode.LINE:
break;
case AbstractInsnNode.FRAME:
populateFrames(OpcodeUtil.OPS_FRAME);
break;
}
}