GWT RPC SerializationException

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?

Answers


Class<? extends Foo> is most likely a problem. As far as I know GWT simply don't know how to serialize-deserialize Class instance (it has code only for serializing normal objects, enums and arrays and there is no CustomFieldSerializer). So try to use classnames instead of Class instances.


Need Your Help

Can anyone recommend a C++ std::map replacement container?

c++ stdmap

Maps are great to get things done easily, but they are memory hogs and suffer from caching issues. And when you have a map in a critical loop that can be bad.

C++ SDL header file errors

c++ header sdl

I'm following a tutorial and it said at one point it should compile, but it errored.