StackOverflowError when serializing an object in Java

后端 未结 8 1664
眼角桃花
眼角桃花 2020-11-28 13:56

I am writing an application in Java using Swing. I am trying to implement functionality to save and load simulation states for at simulation i am running. The entire simulat

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 14:24

    You should consider reimplementing the writeObject / readObject methods of your Simulation class in order to serialize only the relevant data (and not the entire contained object structure by default) or tagging transient your not to be serialized objects. You can also use the Externalizable interface if needed.

    BTW, you may want to read this interesting article to begin with.

提交回复
热议问题