Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert bytecode by 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 in visitCode() and visitInsn(int inst), but not working in isitLocalVariable(name, desc, signature, start, end, index)

It doesn't invoke myMethod().

Could anyone help me? Thanks

like image 262
RobinBattle Avatar asked Jul 28 '26 01:07

RobinBattle


1 Answers

This method visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) is only for a local variable declaration and couldn't contain any code.

like image 62
MikhailDudarev Avatar answered Jul 29 '26 18:07

MikhailDudarev