如果您的可序列化对象具有任何writeObject方法,则将调用该对象,否则将调用defaultWriteObject方法。
使用反射可以调用私有方法。如果您在该方法writeSerialData中看到ObjectOutputStream类的源代码,则下面的代码将回答您的问题。
if (slotDesc.hasWriteObjectMethod()) { // through reflection it will call the Serializable objects writeObject method} else {// the below is the same method called by defaultWriteObject method also.writeSerialData(obj, desc);}


