According to AutoValue documentation annotating the abstract class with @GwtCompatible(serializable = true) and implementing serializable should be enough for the generated value class to be usable in GWT RPCs. Yet, with the class below I am getting the following error:
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}
I tried various variant (like only implementing the regular Serializable) without success. What is wrong with the class?
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 file includes
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 version: 2.6.0