Why is it necessary to use the marker interface to serialize an object?

Why can't I avoid this if I want all the objects in my application to be serialized?

Update: I know that some class cannot be serialized as a stream, but the java system also knows that Thread is not serializable, why doesn't it automatically control it?

I would like to know if there are fundamental reasons.

+3
source share
3 answers

Why can't I avoid this if I want all the objects in my application to be serialized?

Just because Java serialization works this way.

Note that serializing all objects does not make sense.

  • Threadinstances and instances of most classes Streaminclude a critical state that simply cannot be serialized.
  • , .
  • , .
  • , .

, -, ? ? : , , Serializable.

+3

, , , , , , - , . , , , .

+1

? . , . , , FAQ -, 12 . , , . .

-1

Source: https://habr.com/ru/post/1772245/


All Articles