How can I keep GWT from trying to include every serializable class when I use ArrayList

前端 未结 4 895
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 05:30

I have an RPC service in GWT that needs to return a List. The List can be filled with various types of objects, all of which are serializable and all of are referenced elsewher

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-08 06:03

    If you add an ArrayList or similarly an Object field to a serializable object, the GWT compiler has no choice but to include all possible variants in its compilation. You are essentially declaring I can send anything using this field , so the compiler makes sure that you are able to send anything.

    The solution is to declare , using generic parameters, the specific types you are sending. That might require splitting into multiple parameters or classes, but it does keep the code size and compile time down.

提交回复
热议问题