I read some articles saying that in RPC methods a specific collection (like ArrayList
instead List
) should be used. Is this still valid or is this not necessary anymore in the newer versions of GWT? Because in the RPC article in the official documentation this is not mentioned and I saw several examples that use generic collections like List
.
Asked
Active
Viewed 93 times
1

jan
- 3,923
- 9
- 38
- 78
-
It's not necessary to use `ArrayList` instead of `List`. Why do you need this? Is your code not working with `List`? – Braj Aug 19 '14 at 12:34
-
It is working. But I read the performance is better with more specific types because otherwise the compiler needs additional checks for all implementations of the interface. E.g.: See the answer here: http://stackoverflow.com/questions/3059787/gwt-using-listserializable-in-a-rpc-call – jan Aug 19 '14 at 12:55
-
[This](http://stackoverflow.com/questions/6059211/in-gwt-why-shouldnt-a-method-return-an-interface) also seems related. – Baz Aug 19 '14 at 13:26
-
However, in the video in that answer, the guy says that this will only affect compile time (and application size), not run time. – Baz Aug 19 '14 at 13:34
1 Answers
2
It's still valid, given it's a consequence of RPC design (and GWT generator design). If you use List
then you could in theory use any class implementing the interface, so the generator has to take it into account. And generators run before any optimisation happens so they can't tell a specific is/will actually be used by the app (not to mention that it can't tell what the server will return)

Thomas Broyer
- 64,353
- 7
- 91
- 164