Forcing GWT to accept List is implemented as an ArrayList

For some reason, I am attached to model classes using List as Collection Type, and I would like to use a client-side model. However, GWT, of course, does not serialize java.util.List. However, all List implementations in this model are based on ArrayList. So is it possible to tell the GWT that List is an ArrayList?

Edit GWT fails at compile time, since a possible candidate for List is also java.util.Collections.SingeltonList - which cannot be compiled.

I am using GWT 2.1 and Java 1.6.

+4
source share
3 answers

You can use the GWT-RPC blacklist to prevent GWT from trying to compile certain classes in such situations. See this problem .

+3
source

GWT RPC must properly serialize ArrayLists, since they implement java.io.Serializable. Is this really a list that cannot be serialized or a class inside a list?

Another common caveat: do you have a (required) parameterless constructor in your classes?

+1
source

Gwt creates javascript. For each object, List is a more general type, because this compiler tries to generate all the List functions, and the gwt compiler does not know the execution time. And the GWT "serializable" concept is somewhat different from serialization based on the standard Java Serializable interface. see frequently asked questions . Does the GWT RPC system support using java.io.Serializable?

everything regarding serialization rules is described in detail here

+1
source

Source: https://habr.com/ru/post/1332916/


All Articles