R
Roedy Green
But this has nothing to do with deserialization, of course.
It would if the object coming in the wire has never been seen before.
We have the class files on tap, but they have not yet been loaded.
But this has nothing to do with deserialization, of course.
Roedy said:Are there circumstances where fields of non-serialisable superclasses
don't get saved/restored?
EJP said:There are no circumstances where they *do* get saved/restored. They're
not serializable, so they don't get serialized or deserialized. They get
whatever the default contructor and/or the variable initializers put there.
Roedy said:It would if the object coming in the wire has never been seen before.
We have the class files on tap, but they have not yet been loaded.
OK, not "nothing" to do with serialization, but static fields are not
deserialized, they're initialized when the class is loaded, whether because of
serialization or for any other reason. In that sense the initialization is
not dependent on (de)serialization, which is what I was trying to convey.
Roedy said:Normally class loading happens as a side effect of running constructor
or a method. With serialisation reconstitution, you don't run any
methods. So some special mechanism is necessary to get the class
loaded.
It might call <clinit> or it might use reflection to call some
innocuous method of Object.
Roedy said:Normally class loading happens as a side effect of running
constructor
or a method. With serialisation reconstitution, you don't run any
methods.
Regardless of why the class loads, initialization of the static members is a
function of class loading, not deserialization.
I'd say yes.Roedy said:But then what causes class loading? Perhaps it does a classForName .
Does that actually force the load?
Lew said:More precisely, what the no-arg constructor put there.
EJP said:More precisely still, the state is the same as if you had invoked the
no-arg constructor, consisting of what super(), the variable
initializers, the instance initialization block {}, and the code in the
no-arg constructor put there.
Lew said:Somewhat redundant, actually. All that happens if you invoke the no-arg
constructor, so saying "what the no-arg constructor put there" subsumes
the rest.
Rob said:I had a good dream about a woman last night. Try it some time [sic].
Rob
http://cbmc64.blogspasm.sputum
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.