Find path to offending non-Serializable member variable

前端 未结 3 2038
隐瞒了意图╮
隐瞒了意图╮ 2020-12-31 17:42

In Java, Serialization makes reading and writing objects to streams REALLY easy. For instance, the following code snippet is mostly all it takes to write objects to a strea

3条回答
  •  [愿得一人]
    2020-12-31 18:17

    This is a strange question - you're wanting to determine at runtime what you should be doing at compile time. In theory, the path to the object shouldn't matter - you need to find the objects that reference things that aren't serializable to fix your code.

    That said, you could write a simple recursive tree crawler using reflection. That said, you might be able to get away with implementing your own ObjectInputStream that logs the objects coming in appropriately. I recommend taking a look at the source for more detail

提交回复
热议问题