GWT 2.6.1 编译时数字转换错误

Error of number conversion in GWT 2.6.1 when compiling

在旧项目迁移过程中,我将 GWT 的版本从 2.0.4 更改为 2.6.1,将 GXT 从 2.2.0 更改为 2.3.1a。当我的模块被编译为 javascript 时,出现以下错误:

'jar:file:/C:/Users/User/.m2/repository/com/google/gwt/gwt-user/2.6.1

/gwt-user-2.6.1.jar!/com/google/gwt/i18n/client/NumberFormat.java'
[INFO]       [ERROR] Line 941: Incompatible conditional operand types Number and BigDecimal
[INFO]       [ERROR] Line 942: Cannot cast from Number to BigDecimal
[INFO]       [ERROR] Line 947: The method valueOf(int) is undefined for the type BigDecimal
[INFO]       [ERROR] Line 952: Incompatible conditional operand types Number and BigInteger
[INFO]       [ERROR] Line 953: Cannot cast from Number to BigInteger
[INFO]       [ERROR] Line 958: The method valueOf(int) is undefined for the type BigInteger

我使用 org.codehaus.mojo 的 gwt-maven-plugin。认为这可能是由于 java 的版本不兼容,但我尝试了 1.5 和 1.7。

提到的 NumberFormat.java

片段
   public String format(Number number) {
    if (number instanceof BigDecimal) {
      BigDecimal bigDec = (BigDecimal) number;
      boolean isNegative = bigDec.signum() < 0;
      if (isNegative) {
        bigDec = bigDec.negate();
      }
      bigDec = bigDec.multiply(BigDecimal.valueOf(multiplier));
      StringBuilder buf = new StringBuilder();
      buf.append(bigDec.unscaledValue().toString());
      format(isNegative, buf, -bigDec.scale());
      return buf.toString();
    } else if (number instanceof BigInteger) {
      BigInteger bigInt = (BigInteger) number;
      boolean isNegative = bigInt.signum() < 0;
      if (isNegative) {
        bigInt = bigInt.negate();
      }
      bigInt = bigInt.multiply(BigInteger.valueOf(multiplier));
      StringBuilder buf = new StringBuilder();
      buf.append(bigInt.toString());
      format(isNegative, buf, 0);
      return buf.toString();
    } else if (number instanceof Long) {
      return format(number.longValue(), 0);
    } else {
      return format(number.doubleValue());
    }
  }

问题出在 Maven 中已弃用的 gwt-math 依赖项。看起来 gwt-math 不再受支持,其内容已移至 gwt-user。