Paste bytecode using ASM

For example, in a subclass of MethodApdaptor

this.visitLdcInsn(className);
this.visitLdcInsn(methodName);
this.visitMethodInsn(INVOKESTATIC,
            "trace/profiler/Profile",
        "myMethod",
        "(Ljava/lang/String;Ljava/lang/String;)V");

This piece of code works fine when writing to visitCode()and visitInsn(int inst), but does not work at isitLocalVariable(name, desc, signature, start, end, index)

It does not call myMethod ().

Can anyone help me? Thanks

+3
source share
1 answer

This method is visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) only for local declaration of variables and cannot contain any code.

+1
source

All Articles