我正在尝试使用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
答案 0 :(得分:2)
答案 1 :(得分:0)
仅供参考,我认为java.math应该可以在当前版本的GWT中使用,尽管可能不在2.0.3中。例如,请参阅the JRE emulation reference for GWT 2.2,可能是第一个可用的版本。
我不知道与gwt-java-math结合会发生什么;可能Guava本身需要声明对其模块的依赖才能使其工作?
我们确实需要更好地确定和宣传Guava需要哪个版本的GWT,包括针对Guava(而不仅仅是我们的内部版本)运行我们的GWT测试来验证。