本文整理匯總了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()");
}
}
}
}
}
}