I am trying to send an object across GWT RPC (GWT 2.4). The object includes an object which includes the following field:
@Serialized
private Map<Class<? extends Foo>, Foo> fooMap = ImmutableMap.of();
Foo is defined as:
public interface Foo extends Serializable {
}
When fooMap is empty, it works fine. When it is populated, the GWT RPC fails with a SerializationException. (The server is never hit.) The only type of Foo in fooMap is from this class:
public class FooImpl implements Foo {
private static final long serialVersionUID = 1L;
private long bar;
private float baz;
private int batz;
...
}
What am I doing wrong? FooImpl shouldn’t be causing any problems. Every class has a no-arg constructor. I don’t need getters and setters for every private field of every serialized object, right? Is Class<? extends Foo> a problem?
Class<? extends Foo>is most likely a problem. As far as I know GWT simply don’t know how to serialize-deserializeClassinstance (it has code only for serializing normal objects, enums and arrays and there is no CustomFieldSerializer). So try to use classnames instead ofClassinstances.