stringgwtgwt2

String.split() method bug in GWT 2.0.3


I'm upgrading a GWT project from GWT 1.7.1 to currently newest version 2.0.3. It seems that new GWT broke String.split(String regex) method - I get the following error on the Javascript side:

this$static is undefined

This happens in this line of my .nocache.js file:

if (maxMatch == 0 && this$static.length > 0) {

...which happens to be a part of String split method equivalent in Javascript.

Is there a cure for this, apart from doing string splitting myself?


Solution

  • A possible workaround is to write a JSNI method that wraps around the standard JavaScript split function, something like this (note: code not tested :))

    public static final native String[] split(String string, String separator) /*-{
        return string.split(separator);
    }-*/;
    

    The closest thing on the GWT Issues list is Issue 3071, but I'd just stick with JSNI on this one (just like I stick with JSNI for regular expressions).