How is object of serialized class created dynamically without calling the constructor when de-serialization in java?
What is the mechanism used by the JVM to create the object instance?
How is object of serialized class created dynamically without calling the constructor when de-serialization
Share
It depends on the JVM, but the Sun/Oracle/OpenJDK uses sun.misc.Unsafe.allocateInstance(Class)
http://www.docjar.com/html/api/sun/misc/Unsafe.java.html
This allows you to create new instances of just about anything e.g. enums, but not new instances of Class.