What ASM Visitor Method gets called for type annotation on catch

Deadly 提交于 2019-12-12 01:49:53

问题


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

   try{
    } catch (@TypeAnno7 RuntimeException re){

    }

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?


回答1:


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.



来源:https://stackoverflow.com/questions/29189158/what-asm-visitor-method-gets-called-for-type-annotation-on-catch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!