marvc1
marvc1

Reputation: 3699

What would prevent a class from being serializable?

What would prevent a class from being serializable?

I understand that a class is not serializable by default because enabling serialization introduces overhead. But are there characteristics of certain classes that would prevent them from being serialized?

If it's relevant, I am specifically thinking about XML serialization.

Upvotes: 2

Views: 227

Answers (1)

Mark Byers
Mark Byers

Reputation: 838276

There are objects which can't be serialized. If the object contains handles to external resources then these often cannot be serialized in a meaningful way.

Examples:

  • Open TCP connections.
  • Transaction objects.
  • Open file handles.

Upvotes: 7

Related Questions