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:
自己出现的问题跟这个差不多,想访问Annotation Processor生成的java文件中的类。
最后解决办法:就是生成类中必须实现某个接口,而这个接口本身是已经存在的。然后调用这个接口就可以实现了。