Monday, July 20, 2015

Re: @GwtUnreachable annotation

On Monday, July 20, 2015 at 6:26:39 PM UTC+3, Jens wrote:
Why does @GwtIncompatible doesn't work for you? The result is the same as your proposed @GwtUnreachable annotation.

It just doesn't work. My code is:



    private void downloadJre() {
        // empty

    private void download() {
        if (!GWT.isClient()) {
results in error like this: (At least in GWT 2.7.0 superdevmode)

The error is the same as if `downloadJre()` was non-existent method.

And my understanding is that it should work that way according to GwtIncompatible javadoc: GWT just does not see function annotated with @GwtIncompatible.
You might need to refactor your code a bit if GWT complains about imports used by downloadJre()
but that would probably be the same case for @GwtUnreachable. I used @GwtIncompatible once to avoid super-source and it did the job just fine (used it for some shared number format class).

Also instead of super sourcing no-op implementations for everything that downloadJre() uses (but GWT does not support), you should super source the whole download() method. Basically you implement the download() method once for a JRE environment and then provide a super sourced version of download() that works in the browser with GWT. Because your download() method is probably in a larger class you should refactor it out into its own class so you only need to super source as less code as possible.

That should work, but harder to maintain that simple if+annotation.


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