groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Laforge <>
Subject Re: java parser usage in Groovy
Date Wed, 24 Jun 2015 08:32:48 GMT
Annotation processors can modify classes and such, and indeed, this
couldn't work for Groovy classes.
But in the case of Dagger 2, it's just generating new classes, and not
modifying those that are annotated.
So Dagger 2 is happy with this as it doesn't have to change Groovy's
classes at all.
So the stubs are enough for Dagger 2.

2015-06-24 7:08 GMT+02:00 Jochen Theodorou <>:

> Am 23.06.2015 23:58, schrieb werickson:
>> I guess letting groovy do a annotation processor implementation is not
>>> really a solution, is it?
>> There is a JIRA for this:
>> Theoretically it might be possible to wrap a Java Annotation Processor
>> inside of a Groovy AST, but correctly mapping the helper classes that Java
>> provides to Annotation Processors seemed difficult when I last looked into
>> it.
>> When I talked to C├ędric and Guillaume about adding support for Java
>> Annotation processors to Groovy earlier this year, they suggested the
>> joint
>> compilation stub approach for getting the Dagger2 annotation processor
>> working with Groovy.
> Actually thinking about this further I see that there is a part that I
> don't understand.
> Dagger2 is an annotation processor, as such it works on java sources. Ok,
> no problem, it can work on stubs. But I thought it will also change the
> class generation. As such it should either modify the sources inside javac
> or modify the resulting class files on bytecode level. In case 1 it cannot
> do changes to groovy files, because the stubs are forgotten later. In case
> 2 it can still work on precompiled files. Normally annotation processors do
> case 1 using the tree api (or even javac internals). But as I said, this
> can't work for Groovy, not if the file's AST itself is supposed to be
> modified.
> So I can see how you can write a module in Groovy to be used by dagger2.
> But I fail to see how Dagger2 is supposed to handle a Groovy file with an
> @Inject annotation. Can somebody explain?
> bye blackdrag
> --
> Jochen "blackdrag" Theodorou
> blog:

Guillaume Laforge
Groovy Project Manager
Product Ninja & Advocate at Restlet <>

Social: @glaforge <> / Google+

View raw message