什么是ASM Visitor方法在catch上被要求进行类型注释 [英] What ASM Visitor Method gets called for type annotation on catch

查看:217
本文介绍了什么是ASM Visitor方法在catch上被要求进行类型注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码段,我使用ASM进行了分析

I have the following code snippet, which I analyze with ASM

   try{
    } catch (@TypeAnno7 RuntimeException re){

    }

我找不到为Annotation调用的正确方法.我认为

I can't find the right method that gets called for the Annotation. I thought MethodVisitor.visitTryCatchAnnotation would do the trick, but it doesn't get called.

那么:使用的正确方法是什么?所述方法调用哪种代码?

So: what is the correct method used? And for what kind of code does the method mentioned get called?

推荐答案

除非try主体包含一些代码,否则Java编译器不会为try/catch生成任何字节码(否则,catch块将永远无法运行,因此一种消除无效代码的形式),您可以使用javac -p进行验证.将一些代码添加到try主体中,然后应调用visitTryCatchAnnotation.

The Java compiler does not generate any bytecode for a try/catch unless the try body contains some code (otherwise, the catch block could never actually run, so it's a form of dead code elimination), which you can verify using javac -p. Add some code to the try body, and then the visitTryCatchAnnotation should be called.

这篇关于什么是ASM Visitor方法在catch上被要求进行类型注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆