GWT generators not only generate code, they also tell GWT to use it; whereas annotation processors only generate code that then needs to be used by some other code (either referenced directly in the code, or loaded through reflection – something that's not possible in a GWT environment though).
The way generators and processors are invoked is very different too. GWT instantiates and runs a generator for each type that needs processing, for each permutation (this stems from the above difference: the generator tells GWT which class to actually instantiate for the given type passed as input), whereas an annotation processor is instantiated once per compilation and then invoked repeatedly for each processing round, where each round processes a set of types.
GWT has support for permutations, where the generated class can be different depending on the binding properties' values to achieve deferred binding (GWT generators are just one facet of deferred binding). Note that GWT generators don't actually have to generate anything, they can also just select an existing class. You can only approximate this with annotation processors by generating code that will select the given implementation at runtime.
Put differently, if you generate a specific implementation for locales en-US
and fr-FR
; with a GWT generator, when the generator is invoked, it knows which locale the permutation is about, so it can tell GWT to use that particular implementation. The net result is as if the GWT.create()
in the code was replaced with a new TheGeneratedClass()
, and that class can be different depending on the permutation (e.g. MyMessagesImpl_en_US
vs. MyMessagesImpl_fr_FR
). With an annotation processor, you'd have to generate both classes and then dynamically (at runtime) select among them, depending on the context (you could generate a factory to help doing that, but you'd still have to somehow feed the factory with the current context, e.g. the current locale).
Finally, the way you trigger them is different. GWT's deferred binding is only triggered by GWT.create()
in the code, i.e. instantiation of a yet-to-be-determined-at-the-time-of-writing class; whereas annotation processors are triggered by the mere presence of an annotation on an element (a package, a type, a field, a method, a parameter, or even in Java 8 a type-parameter or anywhere a type is used).
GWT generators and annotation processors are different things, made with different goals. In many cases you could use one or the other almost interchangeably (e.g. AutoBeans, RequestFactory, the Editor framework, PlaceHistoryMappers in GWT could be done using annotation processors), but not always.