< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.processor/src/org/graalvm/compiler/processor/AbstractProcessor.java
Print this page
rev 52509 : [mq]: graal2
*** 30,44 ****
--- 30,46 ----
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
+ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.processing.FilerException;
import javax.annotation.processing.ProcessingEnvironment;
+ import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
*** 60,69 ****
--- 62,85 ----
*/
public ProcessingEnvironment env() {
return processingEnv;
}
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ // In JDK 8, each annotation processing round has its own Elements object
+ // so this cache must be cleared at the start of each round. As of JDK9,
+ // a single Elements is preserved across all annotation processing rounds.
+ // However, since both behaviors are compliant with the annotation processing
+ // specification, we unconditionally clear the cache to be safe.
+ types.clear();
+
+ return doProcess(annotations, roundEnv);
+ }
+
+ protected abstract boolean doProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv);
+
private final Map<String, TypeElement> types = new HashMap<>();
/**
* Gets the {@link TypeMirror} for a given class name.
*
< prev index next >