1. Gson doesn't serialize fields defined in subclasses stackoverflow.comFor some unknown reason if I have:
|
2. will subclass gets serialized? coderanch.comPrashanth, Man, I thought I was going to get off easy on this one. No, the non-serializable superclass of a serializable class is not serialized. Notice I say "the", not "a", because at some point in every class's parentage there is a non-serializable class - Object is not serializable. There are a couple of points to address here: 1) Suppose C ... |
3. making subclasses serializable necessary? coderanch.com |
4. Best Practices for Serializing Subclass whose Superclass is NOT Serializable coderanch.comimport java.io.*; class Player{ Player(){System.out.print("p");} } class CardPlayer extends Player implements Serializable{ CardPlayer(){System.out.print("c");} public static void main(String[] args){ CardPlayer c1 = new CardPlayer(); try{ FileOutputStream fos = new FileOutputStream("play.txt"); ObjectOutputStream os = new ObjectOutputStream(fos); os.writeObject(c1); os.close(); FileInputStream fis = new FileInputStream("play.txt"); ObjectInputStream is = new ObjectInputStream(fis); CardPlayer c2 = (CardPlayer) is.readObject(); is.close(); }catch(Exception x){} } } |
5. Regarding Serializable and subclasses. forums.oracle.comI have a an abstract parent class called 'Information' which implements Serializable and which has an abstract method called init(). There are 2 subclasses that extend the parent class Information called SInformation_1 and SInformation_2 and implement the method init(). Now as the parent class is Serialized,will the concrete subclasses also be Serializable? |
6. Serialize all subclasses automatically?? forums.oracle.com |