Sunday, December 28, 2014

Finding out what Primary Linker is Active, inside a "Post" Linker

I'm trying to solve a problem.  I've written a custom "post" (non-primary) linker extending AbstractLinker, but I want it to have different behavior depending on what the primary linker is.  For example, the primary linker could be the "standard" linker or the xsiframe linker. I could attempt to guess by using GWT.getVersion() in conjunction with the ConfigurationProperty set passed to the linker, but I want something more robust.  (I say "guess" because the linker setting doesn't show up in the ConfigurationProperty set passed into link() unless you set it in your module definition, so if it's not present, presumably you have to use GWT.getVersion() to guess what the primary linker is.)

Now, I've found from the source that ModuleDef defines an API getActivePrimaryLinker(), but I'm not sure how to get the ModuleDef (for the module active when link() on my "post" linker is called).  The only idea I have right now is to use Java Reflection to invoke the private method ModuleDefLoader.tryGetLoadedModule().  (Since the linker is "real" Java and won't be compiled to JS, I assume Reflection will work.)

Obviously this is a huge hack.  How should I be checking the primary linker?

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