Strange GWT serialization exception when overiding method of serialized object
- by Flueras Bogdan
Hi there!
I have a GWT serializable class, lets call it Foo.
Foo implements IsSerializable, has primitive and serializable members as well as other transient members and a no-arg constructor.
class Foo implements IsSerializable {
// transient members
// primitive members
public Foo() {}
public void bar() {}
}
Also a Service which handles RPC comunication.
// server code
public interface MyServiceImpl {
public void doStuff(Foo foo);
}
public interface MyServiceAsync {
void doStuff(Foo foo, AsyncCallback<Void> async);
}
How i use this:
private MyServiceAsync myService = GWT.create(MyService.class);
Foo foo = new Foo();
...
AsyncCallback callback = new new AsyncCallback {...};
myService.doStuff(foo, callback);
In the above case the code is running, and the onSuccess() method of callback instance gets executed.
But when I override the bar() method on foo instance like this:
Foo foo = new Foo() {
public void bar() {
//do smthng different
}
}
AsyncCallback callback = new new AsyncCallback {...};
myService.doStuff(foo, callback);
I get the GWT SerializationException.
Please enlighten me, because I really don't understand why.