Friday, January 27, 2017

GWT 2.7: access public static final field in JSNI results as undefined in SuperDevMode

Hi all,

during development I ran into a problem and I had to dig a bit deeper to find the root cause. Perhaps someone can explain why this happens.

I use GWT 2.7. And I have a class with some constants. For example something like this:

public class MyConstants {      public static final String SPECIAL_MARKER = "marker";    }  

Now I try to use this in a JSNI method in another class, for example in this way:

...    public static native void doSomethingWithMarker() /*-{     var cm = @my.package.MyConstants::SPECIAL_MARKER      $wnd.alert(cm);  }-*/;    ...  

In classic dev mode and in the compiled version this is working. In SuperDevMode cm is undefined.

Now, I remove the final and voila, it even works in SuperDevMode.
So obviously the final is a problem. But why is it working in classic and compiled mode? Is this simply a bug or is there a better way to use such constants?


You received this message because you are subscribed to the Google Groups "GWT Users" 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