Annotation processors and the --processor-module-path

Eirik Bjørsnøs eirbjo at gmail.com
Mon Nov 21 00:35:13 UTC 2016


Assuming Java 9 annotaton processors might need to provide
javax.annotation.processing.Processor as a service, I added:

provides javax.annotation.processing.Processor with
com.example.processor.ProcessorUsingJavaXmlBind

to module-info.java.

But still, no dice.

Eirik.

On Mon, Nov 21, 2016 at 1:22 AM, Eirik Bjørsnøs <eirbjo at gmail.com> wrote:

>
> Following up on my example, I updated both the annotation processor and
> the example-module to be proper Java 9 modules with module-info.java.
>
> Maven then moved the annotation processor to the --module-path for
> example-module's compilation.
>
> That did not seem to work. The processor wasn't loaded at all.
>
> Then I saw that javac also has a --processor-module-path which seemed
> promising.
>
> However, my processor was not loaded at all.
>
> First, let us verify that out module is actually a module now:
>
> $ java -p ~/.m2/repository/com/example/annotation-processor/1.0-
> SNAPSHOT/annotation-processor-1.0-SNAPSHOT.jar  --list-modules
> com.example.annotation.processor
> com.example.annotation.processor (file:///$HOME/.m2/repository/
> com/example/annotation-processor/1.0-SNAPSHOT/annotation-processor-1.0-
> SNAPSHOT.jar)
>   requires mandated java.base
>   requires java.compiler
>   requires java.xml.bind
>   conceals com.example.processor
>
> Then, compile the example module, now using --processor-module-path:
>
> $ javac --processor-module-path ~/.m2/repository/com/example/
> annotation-processor/1.0-SNAPSHOT/annotation-processor-1.0-SNAPSHOT.jar
> -sourcepath src/main/java src/main/java/module-info.java
> src/main/java/com/example/module/SomeClass.java -g -nowarn -target 1.9
> -source 9
>
> No output, the annotation-processor was not loaded.
>
> Is there some trick needed to load annotation processors as modules?
>
> Eirik.
>


More information about the jigsaw-dev mailing list