I am getting the following serialization error and I am trying to read my object that I saved to a file
java.io.InvalidClassException: com.testGame.scoreCard; Incompatible class (SUID): com.testGame.scoreCard: static final long serialVersionUID =-5895378336422852901L; but expected com.testGame.scoreCard: static final long serialVersionUID =0L;
at java.io.ObjectInputStream.verifyAndInit(ObjectInputStream.java:2376)
at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1658)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:683)
at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1799)
at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1999)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1956)
But what I don’t get is why scoreCard is serialized in the first place? The class(object) that I am writing and reading is serialized and does not call or make use of scoreCard class. Why would it complain about that class? Is there a way to see why this scoreCard is involved? ( I am using eclipse btw)
Thank you
Could it be that class that you are trying to restore depends indirectly on ScoreCard, through another class for example?
To see dependencies in Eclipse you can click on a class name or method name and press Ctrl+Shift+G, it will show you all the places where class or method is used.
Another way to discover dependencies is to click on a method name and press Ctrl+Alt+H, it will show you call graph that you can discover further.