您的位置:首页 > 其它

Annotation Processor - How to get the Class it is processing

2016-05-13 14:11 351 查看
You are unable to access the Class the Annotation Processor is processing because the Class has not been compiled yet. Instead Java offers the analogous Elements api for reflection-style inspection of the input source.

The Element (which you found by using 
roundEnv.getRootElements()
)
has much more information about the class being compiled than just its name. A ton of useful information can be found by using the ElementVisitors:

http://stackoverflow.com/questions/18034626/annotation-processor-how-to-get-the-class-it-is-processing

自己出现的问题跟这个差不多,想访问Annotation Processor生成的java文件中的类。

最后解决办法:就是生成类中必须实现某个接口,而这个接口本身是已经存在的。然后调用这个接口就可以实现了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: