AutoValue のドキュメントによると、@GwtCompatible(serializable = true)で抽象クラスに注釈を付け、serializableを実装するだけで、生成された値クラスを GWT RPC で使用できるようになります。それでも、以下のクラスでは、次のエラーが発生します。
Caused by: com.google.gwt.user.client.rpc.SerializationException:
Type 'com.my.package.client.types.AutoValue_PersonLocalData' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded.
For security purposes, this type will not be serialized.: instance = PersonLocalData{title=Dr., givenName=Philip, familyName=Mortimer}
さまざまなバリアント(通常のシリアライズ可能のみを実装するなど)を試しましたが、成功しませんでした。クラスの何が問題になっていますか?
import java.io.Serializable;
import com.google.auto.value.AutoValue;
import com.google.common.annotations.GwtCompatible;
import com.google.gwt.user.client.rpc.IsSerializable;
@AutoValue
@GwtCompatible(serializable = true)
public abstract class PersonLocalData
implements IsSerializable, Serializable {
public static final long serialVersionUID = 1L;
public static PersonLocalData create(
String title,
String givenName,
String familyName) {
return new AutoValue_PersonLocalData(
title, givenName, familyName);
}
public abstract String getTitle();
public abstract String getGivenName();
public abstract String getFamilyName();
}
Gradle ファイルに含まれるもの
compile 'com.google.guava:guava:18.0'
compile 'com.google.guava:guava-gwt:18.0'
compile 'com.google.auto.value:auto-value:1.1'
GWT バージョン: 2.6.0