Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use Externalizable instead of writeReplace+readResolve?

In a couple of places I'm using writeReplace and readResolve, which sometimes gets quite verbose. I wonder if using Externalizable could be better (actually, I don't think so, because my objects are mostly immutable, but I may be wrong). Could you give me some good examples of using Externalizable?

like image 558
maaartinus Avatar asked Nov 27 '22 11:11

maaartinus


1 Answers

I don't see how they are even comparable. writeReplace() etc writes a surrogate object for cases when you want to do that; Externalizable takes over the entire serialization of the current object and its base objects.

What was your motivation fo using writeReplace()?

like image 150
user207421 Avatar answered Nov 29 '22 02:11

user207421