Modular annotation processor registration was: Scopes in the Jigsaw module system

Alex Buckley alex.buckley at oracle.com
Mon Aug 20 15:37:15 PDT 2012


On 8/20/2012 3:26 PM, Jaroslav Tulach wrote:
> If we want to have processors separated from annotations, then we also need a
> link from the annotation to its processor. I guess a meta-annotation like:
>
> @Target(ElementType.ANNOTATION_TYPE)
> @Retention(RetentionType.CLASS)
> @interface WhichModuleProvidesMyProcessor {
>     String value();
> }
>
> which I could use to define my source annotation
>
> @Retention(SOURCE)
> @WhichModuleProvidesMyProcessor("my.processor.module at 2.7")
> @interface MyAnnotation {
> }
>
> would be enough for javac to know that it has to find and turn on
> my.processor.module in order to compile sources refering to MyAnnotation. If
> the module my.processor.module at 2.7 is not found, the compilation fails with
> error.
>
> Just my 2Kč to discussion about annotation processors (when you get to it).
> -jt

Thanks. While "annotation processing dependencies" are an interesting 
special case, we should stick to the common case of module dependencies 
for now.

I'll just note that binding an annotation type to a processor only works 
when there's an annotation type involved - in general, you can write 
processors which have no interest in annotations whatsoever.

Alex



More information about the jigsaw-dev mailing list