I guess the reason is that you return a raw Map. A raw Map means Map<?
extends Object, ? extends Object> and GWT now has to check all possible sub
classes of Object (= all classes) to see if they can be safely serialized.
GWT then finds the serializable class PathImpl on the classpath and
complaints about a final List variable inside that class (GWT-RPC can't
serialize final fields yet I think).
Also because you have used Map/List GWT has to generate JavaScript code to
support serializing all implementation classes of Map/List even if you
never use them.
When you use GWT-RPC there is a rule very different from what you know from
Java: Be as explicit as possible *(as long as it makes sense)* while
defining your GWT-RPC methods. So instead of a raw Map use a parametrized
HashMap or TreeMap. In your example its probably best to create a DTO
class, e.g.
class MyResult implements Serializable {
ArrayList<Post> posts;
TreeMap<Integer, User> users;
}
Now GWT will only validate MyResult, ArrayList, TreeMap, Integer, Post and
User instead of every class on the classpath and the warning should
disappear. Also only JS serialization code for ArrayList and TreeMap will
be generated instead of code for all List and Map implementations. Being
explicit only counts on GWT-RPC, so for everything else in your app you
should use Map/List/Set.
If your app grows and you plan to have RPC methods with all kinds of
List/Map/Set implementations then you can of course use the Map/List/Set
interface (because then you need serialization code for every
implementation anyways) but you should still parametrize them.
-- J.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/s7IRJutPAVcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.