Annotation processors and the --processor-module-path

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


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