Annotation processors and the --processor-module-path
Jan Lahoda
jan.lahoda at oracle.com
Mon Nov 21 10:17:14 UTC 2016
On 21.11.2016 11:03, Alan Bateman wrote:
> On 21/11/2016 09:46, Eirik Bjørsnøs wrote:
>
>> Alan,
>>
>> | $ javac --help
>> | -processor <class1>[,<class2>,<class3>...]
>> | Names of the annotation processors to run; bypasses default
>> discovery process
>>
>> Why does the "default discovery process" work with --classpath, but not
>> with --processor-module-path?
>>
>> Is it simply an omission, or is this by design?
>>
> If you have `provides javax.annotation.processing.Processor with ...` in
> your module declaration then it should find it. I just checked this
> locally and it works as expected. One of your mails said this wasn't
> working for you, not immediately obvious why from the mails. So if you
> aren't using `provides` then my understanding is that the processor
> needs to be specified via -processor but I don't think there is support
> there for allowing -processor to specify the processor module, hence not
> clear how it could be resolved.
Currently, AFAIK, the processors on module path need to be registered in
the ServiceLoader. For --processor-module-path, "-processor" can be used
to select processors out of those registered in the ServiceLoader. If
--processor-module-path is used and there is no "-processor", all
processors registered in ServiceLoader are considered, AFAIK. Please
note that (as before) the processors are only run if their
SupportedAnnotationTypes match, etc.
I tried a simple example as well, and with the proper "provides" the
annotation processor was run. Is there a testcase we could try?
Jan
>
> -Alan
More information about the jigsaw-dev
mailing list