If you really want to avoid using the transient keyword, you might want to look at the Serial fields of custom fields .
In my last GWT project, I used them to serialize immutable classes, as GWT-RPC had limitations for them.
This is a poorly documented function, and the best explanation I discovered at that time was not in the GWT documentation, but on this large wogwt wiki page . You can also find some examples in the GWT package com.google.gwt.user.client.rpc.core , since GWT uses a lot of these.
Note that CustomFieldSerializers still have some issues, such as issue 2931 and release 3315 . Also, I don't like how they are defined: instead of using static methods, it would be better to let users implement the CustomFieldSerializer<T> interface. We would gain security and inheritance. But this is another discussion, and the GWT compiler can actually use these static methods to improve performance (I have not considered this).
However, this works, and it is good to have them in specific cases.
Etienne neveu
source share