Solve InvalidClassException in java



Contents of page :



What is hierarchy of java.lang. InvalidClassException?

-java.lang.Object
-java.lang.Throwable
 -java.lang.Exception
  -java.lang.IOException
     -java.io.InvalidClassException

InvalidClassException is Checked (compile time exceptions) and UnChecked (RuntimeExceptions) in java ?

java.lang.InvalidClassException is a Checked (compile time) Exception in java.


What are Reasons for InvalidClassException in java?
InvalidClassException is thrown when when the Serialization process faces one of the following problems with a Class in java.

  • If we  don’t define serialVersionUID in the class, and any modification is made in class, then we won’t be able to deSerialize our class because serialVersionUID generated by java compiler for modified class will be different from old serialized object. And deserialization process will end up throwing java.io.InvalidClassException  (because of serialVersionUID mismatch) in java.
  • The class contains unknown datatypes in java.
  • The class does not contains an accessible no-arg constructor.


Read the programs / examples which can throws InvalidClassException and how to solve it in java. Click this Impact of not defining serialVersionUID in class and  avoiding InvalidClassException in java.



Summary -
So in this tutorial we learned What is hierarchy of java.lang. InvalidClassException in java? InvalidClassException is Checked (compile time exceptions) in java. What are Reasons for InvalidClassException in java. Read the programs / examples which can throws InvalidClassException and how to solve it in java.




Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.



RELATED LINKS>

Serialization And Deserialization Tutorial








Serializing & DeSerializing >


Primitive, Custom/reference Data Types, Integer, Floating-Point, Character and String literal, Escape sequence in java, decimal to hexaDecimal and binary conversion program


Also Read :

Core Java tutorial in detail


Collection framework Tutorial in java in detail with diagrams and programs


No comments:

Post a Comment