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

[934 byte] By [YoungWinstona] at [2007-11-26 23:51:44]
# 1

My apologies. I should have worked out from the signature that I can't call defaultReadObject(). I guess my questions should therefore be:

1. Does readResolve() run immediately after a readObject() method, if present?

2. Does readResolve() require a readObject() method?

Winston

YoungWinstona at 2007-7-11 15:30:48 > top of Java-index,Core,Core APIs...
# 2
(1) yes (2) no.
ejpa at 2007-7-11 15:30:48 > top of Java-index,Core,Core APIs...