本文整理汇总了Java中org.objectweb.asm.tree.InsnList类的典型用法代码示例。如果您正苦于以下问题:Java InsnList类的具体用法?Java InsnList怎么用?Java InsnList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InsnList类属于org.objectweb.asm.tree包,在下文中一共展示了InsnList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: emitCode
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
/**
* Creates the new instructions, inlining each instantiation of each
* subroutine until the code is fully elaborated.
*/
private void emitCode() {
LinkedList<Instantiation> worklist = new LinkedList<Instantiation>();
// Create an instantiation of the "root" subroutine, which is just the
// main routine
worklist.add(new Instantiation(null, mainSubroutine));
// Emit instantiations of each subroutine we encounter, including the
// main subroutine
InsnList newInstructions = new InsnList();
List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
while (!worklist.isEmpty()) {
Instantiation inst = worklist.removeFirst();
emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks,
newLocalVariables);
}
instructions = newInstructions;
tryCatchBlocks = newTryCatchBlocks;
localVariables = newLocalVariables;
}
示例2: stringEncryptionTransformer
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
private static void stringEncryptionTransformer(ClassNode classNode) {
if (classNode.superName.equals("org/bukkit/plugin/java/JavaPlugin") || classNode.superName.equals("net/md_5/bungee/api/plugin/Plugin")) {
for (MethodNode methodNode : classNode.methods) {
InsnList nodes = methodNode.instructions;
for (int i = 0; i < nodes.size(); i++) {
AbstractInsnNode instruction = nodes.get(i);
if (instruction instanceof LdcInsnNode) {
if (instruction.getNext() instanceof MethodInsnNode) {
LdcInsnNode ldc = (LdcInsnNode) instruction;
MethodInsnNode methodinsnnode = (MethodInsnNode) ldc.getNext();
if (ldc.cst instanceof String) {
if (methodinsnnode.name.equalsIgnoreCase("\u0972") && methodinsnnode.desc.equalsIgnoreCase("(Ljava/lang/String;)Ljava/lang/String;")) {
methodNode.instructions.remove(methodinsnnode);
ldc.cst = decryptionArray((String)ldc.cst);
}
}
}
}
}
}
}
}
示例3: toNumericalValue
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
public static InsnList toNumericalValue(String what) {
Objects.requireNonNull(what);
InsnList il = new InsnList();
il.add(new LdcInsnNode(what));
il.add(new MethodInsnNode(
INVOKESTATIC,
Type.getInternalName(Conversions.class),
"toNumericalValue",
Type.getMethodDescriptor(
Type.getType(Number.class),
Type.getType(Object.class),
Type.getType(String.class)),
false));
return il;
}
示例4: getEntryPoints
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
private static BitSet getEntryPoints(MethodNode asmNode, Map<AbstractInsnNode, int[]> exitPoints) {
InsnList il = asmNode.instructions;
BitSet entryPoints = new BitSet(il.size());
for (int[] eps : exitPoints.values()) {
if (eps != null) {
for (int ep : eps) entryPoints.set(ep);
}
}
for (TryCatchBlockNode n : asmNode.tryCatchBlocks) {
entryPoints.set(il.indexOf(n.handler));
}
return entryPoints;
}
示例5: addDirectExits
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
private static void addDirectExits(InsnList il, BitSet entryPoints, Map<AbstractInsnNode, int[]> exitPoints) {
int idx = 0; // ignore 0 since it has no preceding instruction
while ((idx = entryPoints.nextSetBit(idx + 1)) != -1) {
AbstractInsnNode prev = il.get(idx - 1);
if (exitPoints.containsKey(prev)) continue;
int type = prev.getType();
if (prev.getOpcode() != Opcodes.ATHROW
&& (prev.getOpcode() < Opcodes.IRETURN || prev.getOpcode() > Opcodes.RETURN)
&& type != AbstractInsnNode.JUMP_INSN
&& type != AbstractInsnNode.TABLESWITCH_INSN
&& type != AbstractInsnNode.LOOKUPSWITCH_INSN) {
exitPoints.put(prev, new int[] { idx });
}
}
}
示例6: getMethodTransformers
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
@Override
public MethodTransformer[] getMethodTransformers() {
MethodTransformer loadWorldTransformer = new MethodTransformer() {
public String getMethodName() {return CoreLoader.isObfuscated ? "a" : "loadWorld";}
public String getDescName() {return "(L" + (CoreLoader.isObfuscated ? "bnq" : Type.getInternalName(WorldClient.class)) + ";Ljava/lang/String;)V";}
public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) {
CLTLog.info("Found method: " + method.name + " " + method.desc);
CLTLog.info("begining at start of method " + getMethodName());
//TransformerUtil.onWorldLoad(WorldClient worldClientIn)
InsnList toInsert = new InsnList();
toInsert.add(new VarInsnNode(ALOAD, 1)); //worldClientIn
toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(TransformerUtil.class),
"onWorldLoad", "(L" + Type.getInternalName(WorldClient.class) + ";)V", false));
method.instructions.insertBefore(method.instructions.getFirst(), toInsert);
}
};
return new MethodTransformer[] {loadWorldTransformer};
}
示例7: newTable
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
public static InsnList newTable(int array, int hash) {
InsnList il = new InsnList();
il.add(ASMUtils.loadInt(array));
il.add(ASMUtils.loadInt(hash));
il.add(new MethodInsnNode(
INVOKEINTERFACE,
selfTpe().getInternalName(),
"newTable",
Type.getMethodType(
Type.getType(Table.class),
Type.INT_TYPE,
Type.INT_TYPE).getDescriptor(),
true));
return il;
}
示例8: get
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
public static InsnList get(int index) {
Check.nonNegative(index);
InsnList il = new InsnList();
if (index <= 4) {
String methodName = "get" + index;
il.add(new MethodInsnNode(
INVOKEINTERFACE,
selfTpe().getInternalName(),
methodName,
Type.getMethodType(
Type.getType(Object.class)).getDescriptor(),
true));
} else {
il.add(ASMUtils.loadInt(index));
il.add(get());
}
return il;
}
示例9: toClosureFieldInstance
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
public RunMethod.ClosureFieldInstance toClosureFieldInstance() {
assert (this.isClosed());
FieldNode fieldNode = instanceFieldNode();
InsnList il = new InsnList();
il.add(new VarInsnNode(ALOAD, 0));
il.add(instantiationInsns());
il.add(new FieldInsnNode(
PUTFIELD,
context.thisClassType().getInternalName(),
instanceFieldName(),
instanceType().getDescriptor()));
return new RunMethod.ClosureFieldInstance(instanceFieldNode(), il);
}
示例10: fetchInstanceInsns
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
private InsnList fetchInstanceInsns() {
InsnList il = new InsnList();
if (this.isClosed()) {
if (this.isPure()) {
il.add(new FieldInsnNode(
GETSTATIC,
instanceType().getInternalName(),
ASMBytecodeEmitter.instanceFieldName(),
instanceType().getDescriptor()));
} else {
il.add(new VarInsnNode(ALOAD, 0));
il.add(new FieldInsnNode(
GETFIELD,
context.thisClassType().getInternalName(),
instanceFieldName(),
instanceType().getDescriptor()));
}
} else {
il.add(instantiationInsns());
}
return il;
}
示例11: dispatchTable
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
private InsnList dispatchTable(List<LabelNode> extLabels, List<LabelNode> resumptionLabels,
LabelNode errorStateLabel) {
InsnList il = new InsnList();
assert (!extLabels.isEmpty());
ArrayList<LabelNode> labels = new ArrayList<>();
labels.addAll(extLabels);
labels.addAll(resumptionLabels);
LabelNode[] labelArray = labels.toArray(new LabelNode[labels.size()]);
int min = 1 - extLabels.size();
int max = resumptionLabels.size();
il.add(new VarInsnNode(ILOAD, LV_RESUME));
il.add(new TableSwitchInsnNode(min, max, errorStateLabel, labelArray));
return il;
}
示例12: createSnapshot
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
InsnList createSnapshot() {
InsnList il = new InsnList();
il.add(new VarInsnNode(ALOAD, 0)); // this
il.add(new VarInsnNode(ALOAD, 0));
il.add(new VarInsnNode(ILOAD, LV_RESUME));
if (context.isVararg()) {
il.add(new VarInsnNode(ALOAD, LV_VARARGS));
}
for (int i = 0; i < numOfRegisters(); i++) {
il.add(new VarInsnNode(ALOAD, slotOffset() + i));
}
il.add(snapshotMethodInvokeInsn());
return il;
}
示例13: resumptionHandler
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
protected InsnList resumptionHandler(LabelNode label) {
InsnList il = new InsnList();
il.add(label);
il.add(ASMUtils.frameSame1(UnresolvedControlThrowable.class));
il.add(createSnapshot());
// register snapshot with the control exception
il.add(new MethodInsnNode(
INVOKEVIRTUAL,
Type.getInternalName(UnresolvedControlThrowable.class),
"resolve",
Type.getMethodType(
Type.getType(ResolvedControlThrowable.class),
Type.getType(Resumable.class),
Type.getType(Object.class)).getDescriptor(),
false));
// rethrow
il.add(new InsnNode(ATHROW));
return il;
}
示例14: transformCode
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
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();
}
示例15: populateClassGraph
import org.objectweb.asm.tree.InsnList; //导入依赖的package包/类
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);
}
}
}
}
}