Sunday, June 22, 2014

Re: Use of reflection inside generator

On Saturday, June 21, 2014 6:31:47 PM UTC+2, Jens wrote:
I don't think reflection will cause issues. I am pretty sure GIN generators also use reflection to call into Guice and execute the GinModule. GWT generators run in a JVM so you can use whatever you want.

BUT, in DevMode or SuperDevMode, code can change be recompiled on-the-fly, and generators be called again, and they should use the newly compiled classes.
That means they have to use a specific classloader. GIN does this since 2.0, previously you had to restart DevMode for GIN to see the changes (because javac would recompile your classes, and restarting the JVM was the only way to "refresh" the classloader).
If you can use JClassType et al. you should do it.

An alternative is to use an annotation processor, independent of GWT. Run it to re-generate Java source code that DevMode/SuperDevMode will pick-up like any other source file.
Dagger and AutoValue work that way, and integrate nicely with GWT (Dagger 2.0 though, not 1.0; 2.0 is still being developed and not yet released).

I believe this is the future of codegen for GWT: generate Java code upfront instead of hooking into the GWT compilation, for every task where it's possible (there'll still be a need for GWT generators I think, at least for the time being).

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment