Developers have to \'opt in\' for making classes serializable by explicitly using SerializableAttribute
. What could go wrong if classes were serializable by default
Serializable classes imply that they have some kind of state that can be written to an external location and read again. For a lot of classes that doesn't make any sense at all - what kind of state does a Thread have, that you could successfully serialize?
It's a little bit philosophical but by convention the default type of a class is not serializable, unless you explicitely define "this class can be serialized".