readResolve() - how is it used?
I have an Object with several static constants, which I would like to substitute for a serialized result if appropriate. I understand that readResolve() is the place to do this, but am unsure whether it works in instead of or in addition to readObject(); and the documentation is unclear on the subject. I therefore have a few questions:
1. If I add a readResolve() method, should I get rid of readObject()?
2. Can I use defaultReadObject() inside readResolve() to set up my internals and then decide whether or not to return a static constant?
3. Do I returnthis
if I decide not to return one of the cached constants?
4. Does readResolve() slow things down? I know I shouldn't worry about this if it's the right thing to do, but I'd be interested to know.
Sorry if this sounds a bit basic, but I've never dealt with serialization before.
Winston

