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
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文件中的类。
最后解决办法:就是生成类中必须实现某个接口,而这个接口本身是已经存在的。然后调用这个接口就可以实现了。
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文件中的类。
最后解决办法:就是生成类中必须实现某个接口,而这个接口本身是已经存在的。然后调用这个接口就可以实现了。
相关文章推荐
- Android Studio编译报错:sdk:minSdkVersion 1 cannot be smaller than version 7 declared in library
- EPC-6708 arm 开发板常用命令等
- Attribute value is quoted with " which must be escaped when used within the value 问题解决
- jQuery-瀑布流-浮动布局(一
- ueditor之ruby on rails 版
- mac idea(intellij idea)常用快捷键
- [ios]字符串不同位置显示不同颜色
- linux sshd远程登陆配置
- PHP获取字符串长度之strlen和mb_strlen的区别
- codeforces 670C Cinema
- SphinxQL with JDBC
- 5分钟学会的新技能,炫酷到没朋友
- android进阶之路:大神问答
- 自定义UITableViewCell时registerNib: 与 registerClass: 的区别
- 【转】【WPF】WPF样式(Style)—触发器
- 如何在大学时代成为编程大神!
- 获取当前SDK的版本
- Host 'XXX' is not allowed to connect to this MySQL server 解决方案
- CSS中的Position属性
- leetcode.200. Number of Islands