编译时GWT 2.6.1中的数字转换错误

时间:2015-08-13 08:08:39

标签: java maven gwt migration gxt

在迁移旧项目期间,我将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());
    }
  }

1 个答案:

答案 0 :(得分:0)

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