Serialization Section Index | Page 3
Method implementations, whether native or pure Java, are not part of the serialized state of an object. There is nothing that prevents objects with native methods from being serialized. It mi...more
I am able to write an object using ObjectOutputStream but when I try to read the object back using ObjectInputStream I get a StreamCorruptedException. How can I overcome this?
The serialization specification says that a StreamCorruptedException is thrown: If the stream header is invalid. If control information not found. If control information is invalid. JDK 1.1.5 or ...more
If your RDBMS supports them, you can store serialized objects as BLOBs. These are JDBC 2.0 features, but take a look at java.sql.Blob, ResultSet and PreparedStatement for more information. more
The Java runtime environment has many features that contribute to security and robustness in a program. For example, the runtime environment enforces access permissions to private, protected, or ...more
Yes, it can. Class implements Serializable, so a object of type Class can be serialized.
Not directly. I/O in Java is performed through streams, and encryption is typically implemented as an algorithm operating on a stream - the input to the stream is clear text, the output is encryp...more
Serialization has improved in three key ways: Speed of reading and writing serialized objects was improved up to 40%. This also dramatically improves RMI performance. Limit of 64K on the size of ...more
Absolutely not! Serialization, i.e. passing an object reference to the writeObject() method of ObjectOutputStream, is not an atomic operation. Serialization involves traversing a graph of object...more
These methods are used to allow an object to provide an alternative representation for itself within an ObjectStream. Consider for instance the common means of implementing an enumerated type:...more
The following piece of code shows you how to do this for the class java.lang.String: String s = new String("test"); Class cl = s.getClass(); long uid = ObjectStreamClass.loo...more
I keep getting a StackOverflowError when I try to serialize my objects. What does this mean and how can I stop it?
Serialization is a recursive process. If your object graph is too deep, then you could overflow the JVM stack. To prevent this, implement readObject() and writeObject() and use your superior kno...more
ObjectOutputStream seems to be holding a reference to all the objects in my large graph, even after I close the stream. This keeps my objects from being garbage collected. Is this a bug?
ObjectOutputStream holds a reference to all the objects in the graph so it can handle circular references by noticing when an object has already been serialized. The only way to clear these refer...more
By implementing Externalizable yourself you can win performance at the cost of flexibility and extra code to maintain. If you implement Externalizable yourself you stream the data directly withou...more
The javadoc documentation for every Swing class contains the warning that "Serialized objects of this class will not be compatible with future Swing releases." What exactly does this mean, and how does it affect how I write my Swing applications?
From the JBuilder documentation: Serializing JavaBeans Serializing an object is the process of turning its state into a sequence of bytes that is neither a .java nor a .class file. Why would you ...more