## 查错

### 追根溯源

private的？为什么不是public？于是我从crash出现的地方一层层点进去看代码，边看边想是哪里出了问题。看着看着我发现这么一段代码，在ObjectOutputStream类的writeObjectInternal方法中：

What?!原来错误是从这里报出来的。我仔细看了一下报错后面的信息，居然是一个其他的类，确实不是一个可以序列化的类。

hashmap-not-serializable

The exception message tells you exactly what the problem is: you are trying to serialize an instance of class SimpleSerializationTest, and that class is not serializable.

Why? Well, you have created an anonymous inner class of SimpleSerializationTest, one that extends HashMap, and you are trying to serialize an instance of that class. Inner classes always have references to the relevant instance of their outer class, and by default, serialization will try to traverse those.