我使用javax.annotation.processing.AbstractProcessor
来处理我的注释,并设置静态字段,但是当我在运行时使用它时,我发现静态字段的值为null,为什么?
例如:
@SupportedAnnotationTypes({"com.qunar.hotel.config.annotation.HConfig"})
public class HConfigAnnotationProcessor extends AbstractProcessor {
public static volatile List<String> list = Lists.newArrayList();
public static String str = null;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
}
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
str="wo lai dao le zhe li";
list.add("test");