ElementType.LOCAL_VARIABLE annotation type

With reflection you can’t retrieve a local variable. So you can’t retrieve an annotation on a local variable via reflection. I think that this kind of annotation is only used for compiler warnings.

You can look http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations.html

Local variable annotations are not retained in class files (or at runtime) regardless of the retention policy set on the annotation type. See JLS 9.6.1.2.

If you wan’t to retrieve method code, you can use JavaParser (http://javaparser.org/).

Leave a Comment