ASM visitLocalVariable不工作

时间:2014-11-07 17:01:52

标签: java local-variables java-bytecode-asm visitor

我正在尝试使用ASM5.0 MethodVisitor通过visitLocalVariable获取有关局部变量的一些信息。但是,当我运行代码时,似乎visitLocalVariable永远不会运行。

public static class ModifierMethodWriter extends MethodVisitor{
    private String methodName;

    public ModifierMethodWriter(int api, MethodVisitor mv, String methodName) {
        super(api, mv);
        this.methodName=methodName;
    }

    // **some other visitor method, which works well, including "visitVarInsn"...**

    public void visitLocalVariable(String name, 
                                   String desc, 
                                   String signature, 
                                   Label start, 
                                   Label end, 
                                   int index) {
        super.visitLocalVariable(name, desc, signature, start, end, index);
        System.out.println("LOCAL - " + name + " TYPE: " + desc + " " + signature + " INDEX: " + index);       
        // nothing get print in this method
    }

}

这是从以下链接http://www.javacodegeeks.com/2012/02/manipulating-java-class-files-with-asm.html

中的演示类ClassModifierDemo.java修改的示例

0 个答案:

没有答案