本文整理汇总了Java中org.objectweb.asm.tree.MethodInsnNode.setOpcode方法的典型用法代码示例。如果您正苦于以下问题:Java MethodInsnNode.setOpcode方法的具体用法?Java MethodInsnNode.setOpcode怎么用?Java MethodInsnNode.setOpcode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.tree.MethodInsnNode
的用法示例。
在下文中一共展示了MethodInsnNode.setOpcode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replaceInvokeSpecial
import org.objectweb.asm.tree.MethodInsnNode; //导入方法依赖的package包/类
private void replaceInvokeSpecial(ClassNode clazz, List<MethodNode> toReplace)
{
for (MethodNode method : clazz.methods)
{
for (Iterator<AbstractInsnNode> it = method.instructions.iterator(); it.hasNext();)
{
AbstractInsnNode insn = it.next();
if (insn.getOpcode() == INVOKESPECIAL)
{
MethodInsnNode mInsn = (MethodInsnNode) insn;
for (MethodNode n : toReplace)
{
if (n.name.equals(mInsn.name) && n.desc.equals(mInsn.desc))
{
mInsn.setOpcode(INVOKEVIRTUAL);
break;
}
}
}
}
}
}
示例2: overclockRenderer
import org.objectweb.asm.tree.MethodInsnNode; //导入方法依赖的package包/类
private static void overclockRenderer(ClassNode node, boolean isObfuscated)
{
// We're attempting to turn this line from Minecraft.runGameLoop:
// this.updateDisplay();
// into this:
// TimeHelper.updateDisplay();
// TimeHelper's method then decides whether or not to pass the call on to Minecraft.updateDisplay().
final String methodName = isObfuscated ? "as" : "runGameLoop";
final String methodDescriptor = "()V"; // No params, returns void.
System.out.println("MALMO: Found Minecraft, attempting to transform it");
for (MethodNode method : node.methods)
{
if (method.name.equals(methodName) && method.desc.equals(methodDescriptor))
{
System.out.println("MALMO: Found Minecraft.runGameLoop() method, attempting to transform it");
for (AbstractInsnNode instruction : method.instructions.toArray())
{
if (instruction.getOpcode() == Opcodes.INVOKEVIRTUAL)
{
MethodInsnNode visitMethodNode = (MethodInsnNode)instruction;
if (visitMethodNode.name.equals(isObfuscated ? "h" : "updateDisplay"))
{
visitMethodNode.owner = "com/microsoft/Malmo/Utils/TimeHelper";
if (isObfuscated)
{
visitMethodNode.name = "updateDisplay";
}
visitMethodNode.setOpcode(Opcodes.INVOKESTATIC);
method.instructions.remove(visitMethodNode.getPrevious()); // ALOAD 0 not needed for static invocation.
System.out.println("MALMO: Hooked into call to Minecraft.updateDisplay()");
}
}
}
}
}
}