2

次のように、Guava 12.0 の FluentIterable を GWT 2.0.3 で使用しようとしています。

import com.google.common.collect.FluentIterable;

class FooPresenter {
   // snip

   private List<NullSafeCheckBox> asCheckboxes() {
      return FluentIterable.from(getDisplay().getMetricInputs())
         .transform(new Function<HasValueChangeHandlers<Boolean>, NullSafeCheckBox>() {
            @Override
            public NullSafeCheckBox apply(@Nullable HasValueChangeHandlers<Boolean> checkbox) {
               return (NullSafeCheckBox) checkbox;
            }
         })
         .toImmutableList();
   }
}

ただし、開発モードで GWT を実行すると、最初のモジュールをロードしようとすると、次のエラーが発生します。

DEBUG: Validating newly compiled units
  ERROR: Errors in 'jar:file:/home/josh/.m2/repository/com/google/guava/guava-gwt/12.0/guava-gwt-12.0.jar!/com/google/common/math/super/com/google/common/math/LongMath.java'
    ERROR: Line 23: The import java.math cannot be resolved

私の pom.xml は次のようになります。

  <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>12.0</version>
  </dependency>
  <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava-gwt</artifactId>
      <version>12.0</version>
  </dependency>

そして、私の Application.gwt.xml は次のように Guava を吸い込みます:

<!-- Guava -->
<inherits name="com.google.common.collect.Collect"/>

アップデート

Arcadian's answerのアドバイスに従って、gwt-math を pom.xml と Application.gwt.xml に追加しました。

  <!-- Guava -->
  <inherits name="com.google.common.collect.Collect"/>
  <inherits name="com.googlecode.gwt.math.Math" />

ホストモードを実行すると、次のエラーが発生します。

DEBUG: Validating newly compiled units
  WARN: Warnings in 'jar:file:/home/josh/.m2/repository/videoplaza-third-party/gwt-incubator/20100204-r1747/gwt-incubator-20100204-r1747.jar!/com/google/gwt/widgetideas/client/impl/GlassPanelImpl.java'
    WARN: Line 30: Referencing deprecated class 'com.google.gwt.user.client.impl.DocumentRootImpl'
    WARN: Line 38: Referencing deprecated class 'com.google.gwt.user.client.impl.DocumentRootImpl'
  ERROR: Errors in 'jar:file:/home/josh/.m2/repository/com/google/guava/guava-gwt/12.0/guava-gwt-12.0.jar!/com/google/common/primitives/UnsignedLong.java'
    ERROR: Line 77: The method bitLength() is undefined for the type BigInteger
    ERROR: Line 79: The method longValue() is undefined for the type BigInteger
    ERROR: Line 200: The method valueOf(long) is undefined for the type BigInteger
    ERROR: Line 202: The method setBit(int) is undefined for the type BigInteger
4

2 に答える 2

2

gwt-java-mathプロジェクトを依存関係として追加してみてください。彼らのウィキで述べたように、

このライブラリは、GWT 自体にマージされる過程にあります! 現在、GWT トランク上にあります。

今後の v2.5 で利用可能になる可能性があります。

于 2012-06-29T08:36:22.283 に答える
0

参考までに、Java.math は GWT の現在のバージョンで利用できるはずですが、おそらく 2.0.3 では利用できないようです。たとえば、GWT 2.2 の JRE エミュレーション リファレンスを参照してください。おそらく最初に利用可能になったバージョンです。

gwt-java-math と組み合わせて何を期待できるかわかりません。おそらく、グアバ自体が機能するためにモジュールへの依存関係を宣言する必要がありますか?

Guava に必要な GWT のバージョンを決定し、宣伝することについては、はるかに優れた方法で行う必要があります。これには、Guava に対して GWT テストを実行して (内部バージョンだけでなく) それを検証することも含まれます。

于 2012-06-29T21:48:54.397 に答える