| Author |
Yikes! Why does Serialization behave like that?
|
Jose Campana
Ranch Hand
Joined: May 28, 2007
Posts: 339
|
|
Greetings! Here I am once again with one of my most pertinent questions, maybe this one has an obvious explanation, but I hope the motto: "There are no dumb questions" applies here as well, anyways.. If I have this: It works. But When I assign an Object to the instance variable, It doesn't work. Could someone please explain to me why this is? Shouldn't the compiler know that even though there's no Object assigned to that instance variable it belongs to a class that it's not serializable? and that can be potentially dangerous... Thanks in advance! sincerely, Jose
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
So you think the first version should not be allowed to work? That would prevent you from implementing this: In other words, although this might be a problem, it's not always a problem, so it makes sense to allow it. Also, what if KingKong were pointing to an instance of
|
[Jess in Action][AskingGoodQuestions]
|
 |
Jose Campana
Ranch Hand
Joined: May 28, 2007
Posts: 339
|
|
Hello there ! Well, Mister Ernest, Sir... yeah, I thought it shouldn't be allowed to work, but I didn't think about polymorphism. I'm sorry, I was wrong, Now I see your point. Thank you very much for the explanation. However....... -In the first version what would be the value of KingKong after deserialization? -- null? Thank you for your time and detailed explanation. Best regards, Jose
|
 |
 |
|
|
subject: Yikes! Why does Serialization behave like that?
|
|
|