简体   繁体   English

GWT 2.0.3中的String.split()方法错误

[英]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. 我正在将GWT项目从GWT 1.7.1升级到当前最新的版本2.0.3。 It seems that new GWT broke String.split(String regex) method - I get the following error on the Javascript side: 似乎新的GWT破坏了String.split(String regex)方法-我在JavaScript端收到以下错误:

this$static is undefined

This happens in this line of my .nocache.js file: 这发生在我的.nocache.js文件的这一行中:

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

...which happens to be a part of String split method equivalent in Javascript. ...恰好是JavaScript中等效的String split方法的一部分。

Is there a cure for this, apart from doing string splitting myself? 除了自己进行字符串拆分之外,还有其他解决方法吗?

A possible workaround is to write a JSNI method that wraps around the standard JavaScript split function, something like this (note: code not tested :)) 一个可能的解决方法是编写一个环绕标准JavaScript split函数的JSNI方法,如下所示(注意:未经测试的代码:))

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). GWT问题列表上最接近的是Issue 3071 ,但我只坚持使用JSNI(就像我坚持使用JSNI来处理正则表达式一样)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM