目录
1、前言
编译时注解处理器,顾名思义,编译时注解处理器。区别于运行时注解处理器,最大的不同是执行期不同,运行时注解处理器是在程序运行阶段执行,而编译时注解则是在javac编译时运行,不会给应用带来运行上的性能问题。
2、AbstractProcessor介绍
AbstractProcessor是一个抽象类,它实现了Processor接口。【注:本文使用jdk1.8.0_271】
Processor的jdk注释
Each implementation of a Processor must provide a public no-argument constructor to be used by tools to instantiate the processor. The tool infrastructure will interact with classes implementing this interface as follows:
1.If an existing Processor object is not being used, to create an instance of a processor the tool calls the no-arg constructor of the processor class.
2.Next, the tool calls the init method with an appropriate ProcessingEnvironment.
3.Afterwards, the tool calls getSupportedAnnotationTypes, getSupportedOptions, and getSupportedSourceVersio