java asm methodvisitor 定义局部变量,ASM字节码工程库中MethodVisitor类的visitLocalVariable()方法有什么作用?...

I am using ASM (for the first time) in an application to create Java class files. This is for the backend of a compiler I am writing.

I read the relevant parts of the ASM documentation and have a question about stack map frames. ASM says it can automatically compute those frames if the class writer is initialized with the appropriate flags. My question is, does that mean I will not ever have to call the visitLocalVariable() method on the method visitors myself? I am not sure what that method does. The documentation does say that I do not need to call the visitFrame() method if frames are computed automatically, but it is silent on the visitLocalVariable() method.

解决方案

visitLocalVariable() describes or defines the debug information as stored in the LocalVariableTable and LocalVariableTypeTable attributes of a Code attribute. They are not required for normal operation and distinct from the information stored in a StackMapTable.

In other words, unless you want to provide debug information, you never need to call visitLocalVariable(), regardless of whether stack map frames are automatically computed or not.

Note the differences of the information stored within these attributes. LocalVariable[Type]Table stores names and [generic] types of local variables and their scope regarding the source level language. StackMapTable stores type information for local variables and operand stack entries regarding the JVM type system for the byte code verifier.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值