Serialization about static fields
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ttk_teng
Posted On:   Friday, April 26, 2002 02:34 AM

Is is true that the static fields can not be serialized
anyway ?


I found that the m_lnkRef not serialized but the CHOICE_ONE and CHOICE_TWO
have valid values when a pointer of class Sample is passed into a SessionBean. I
do not know the reason.


 


Code sample :


class Sample


{


 private static AnotherSampleClass m_lnkRef;


 final static private CHOICE_ONE= 1;


final static private CHOICE_TWO= 2;


}

Re: Serialization about static fields

Posted By:   Kevin_Riff  
Posted On:   Friday, May 10, 2002 01:28 PM

Serialization works on instances of objects. A static field is part of the class itself, not part of any instance of the class. Therefore it would not be appropriate to serialize them.

Re: Serialization about static fields

Posted By:   Bozidar_Dangubic  
Posted On:   Friday, April 26, 2002 03:55 AM

there is no way this compiles in the first place because you did not specify datatype for CHOICE_ONE and CHOICE_TWO. I am assuming they are ints so lets move on. the reason why m_lnkRef did not get serialized is probably because AnotherSampleClass is not serializable and not because it is a static field of class Sample.
About | Sitemap | Contact