Search in sources :

Example 1 with MethodInsnNode

use of jdk.internal.org.objectweb.asm.tree.MethodInsnNode in project OSJR by zeruth.

the class CanvasInjector method setSuper.

public static void setSuper(ClassNode node, String superClass) {
    String replaced = "";
    if (!node.superName.equals(""))
        replaced = node.superName;
    if (!replaced.equals("")) {
        for (Object o : node.methods) {
            final MethodNode mn = (MethodNode) o;
            final ListIterator<?> listIt = mn.instructions.iterator();
            while (listIt.hasNext()) {
                final AbstractInsnNode ain = (AbstractInsnNode) listIt.next();
                if (ain.getOpcode() == Opcodes.INVOKESPECIAL) {
                    final MethodInsnNode call = (MethodInsnNode) ain;
                    if (call.owner.equals(replaced))
                        call.owner = superClass;
                }
            }
        }
    }
    node.superName = superClass;
}
Also used : MethodNode(jdk.internal.org.objectweb.asm.tree.MethodNode) MethodInsnNode(jdk.internal.org.objectweb.asm.tree.MethodInsnNode) AbstractInsnNode(jdk.internal.org.objectweb.asm.tree.AbstractInsnNode)

Aggregations

AbstractInsnNode (jdk.internal.org.objectweb.asm.tree.AbstractInsnNode)1 MethodInsnNode (jdk.internal.org.objectweb.asm.tree.MethodInsnNode)1 MethodNode (jdk.internal.org.objectweb.asm.tree.MethodNode)1