|
50 | 50 | import javax.annotation.processing.Filer; |
51 | 51 | import javax.annotation.processing.RoundEnvironment; |
52 | 52 | import javax.annotation.processing.SupportedAnnotationTypes; |
53 | | -import javax.annotation.processing.SupportedSourceVersion; |
54 | 53 | import javax.lang.model.SourceVersion; |
55 | 54 | import javax.lang.model.element.AnnotationMirror; |
56 | 55 | import javax.lang.model.element.AnnotationValue; |
|
69 | 68 | import org.scijava.annotations.AbstractIndexWriter.StreamFactory; |
70 | 69 |
|
71 | 70 | /** |
72 | | - * The annotation processor for use with Java 8 and earlier. |
| 71 | + * An annotation processor for indexing {@link Indexable} annotations at |
| 72 | + * compile time. The design is inspired by |
| 73 | + * <a href="https://github.com/jglick/sezpoz">Sezpoz</a>, a compile-time |
| 74 | + * indexing library by Jesse Glick. |
| 75 | + * <p> |
| 76 | + * For each annotated class, this processor writes a JSON record of the |
| 77 | + * annotation's attributes into {@code META-INF/json/} under a file named after |
| 78 | + * the annotation type. At runtime, the index can be read to discover annotated |
| 79 | + * classes and inspect their annotation values without loading (and therefore |
| 80 | + * initializing) those classes — avoiding the cost and side-effects of a full |
| 81 | + * classpath scan. |
| 82 | + * </p> |
| 83 | + * <p> |
| 84 | + * For example, SciJava Common's {@link org.scijava.plugin.Plugin} annotation |
| 85 | + * enables the {@link org.scijava.Context} application container to discover |
| 86 | + * and prepare the application including all its plugins without needing to |
| 87 | + * load all of those plugins in advance. Rather, they can be loaded upon first |
| 88 | + * use in each appropriate context, greatly reducing application startup cost. |
| 89 | + * </p> |
73 | 90 | * |
74 | 91 | * @author Johannes Schindelin |
75 | 92 | */ |
76 | | -@SupportedSourceVersion(SourceVersion.RELEASE_8) |
77 | 93 | @SupportedAnnotationTypes("*") |
78 | 94 | public class AnnotationProcessor extends AbstractProcessor { |
79 | 95 |
|
80 | 96 | private RoundEnvironment roundEnv; |
81 | 97 |
|
| 98 | + @Override |
| 99 | + public SourceVersion getSupportedSourceVersion() { |
| 100 | + return SourceVersion.latestSupported(); |
| 101 | + } |
| 102 | + |
82 | 103 | @Override |
83 | 104 | public boolean process(final Set<? extends TypeElement> elements, |
84 | 105 | final RoundEnvironment env) |
|
0 commit comments