On Sunday, June 4, 2017 at 11:57:50 AM UTC+2, Thomas Broyer wrote: > > With a small modification to EventBinder (adding an inherited annotation), > one could write an annotation processor that's fully backwards-compatible > with the current approach. The GWT generator could be changed to simply > return the class generated by the annotation processor as a migration step > before you replace the GWT.create() with an explicit "new", something like: > interface MyEventBinder extends EventBinder<Xxx> {} > private static final MyEventBinder eventBinder = new > Xxx_MyEventBinderImpl(); >
Actually, inherited annotations don't trigger annotation processors when a subclass/subinterface is compiled :-( Adding an annotation to the EventBinder subinterface would work though: @GenerateEventBinder interface MyEventBinder extends EventBinder<Xxx> {} private static final MyEventBinder eventBinder = new Xxx_MyEventBinderImpl(); But if you have to modify your code anyway I'm not sure this is worth it; the linked PoC processor using only @EventHandler might be enough then. There could theoretically be some cases where it would be a more involved change (things like not having @EventHandler methods in the class itself, but only on the superclass, where you'd have to use the EventBinder for the superclass; and/or inheriting @EventHandler defender methods from interfaces, where you'd then have several EventBinder to deal with), and it might possibly break some edge cases (such as an @EventHandler method in a generic superclass where the type arguments are used in the event argument), but I believe in most cases that should Just Workâ˘. > (one big difference of annotation processors is that they're invoked even > if the code wouldn't compile, e.g. applying the annotation to a type > whereas it only targets methods, or if the value of the annotation > properties don't have the correct type, such as @EventHandler(42); with a > GWT generator, those errors would be caught earlier in the process so the > generator is immune to them). > Forget that, this is plain wrong (at least with a recent Java 8 JDK), the generator is only called if the annotation is correctly applied. It might have been the case with older versions of javac, or possibly when looking at other things than the ones the annotation processor has been asked to process; I'd swear I've seen cases where a processor would be invoked and had to check for some annotation usage because the compiler hadn't checked them yet (and thus had to ignore them to let the compiler do its job), couldn't reproduce it though. -- You received this message because you are subscribed to the Google Groups "GWT Contributors" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/7985b588-5814-4c40-a316-a0cdc0b78745%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.