Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String.split() method bug in GWT 2.0.3

Tags:

string

gwt

gwt2

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?

like image 614
Domchi Avatar asked Jan 19 '26 10:01

Domchi


1 Answers

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).

like image 87
Igor Klimer Avatar answered Jan 22 '26 17:01

Igor Klimer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!