In Java 9 the internal representation of String has been changed from char array to byte array.
Consider I'm serializing my String data on a system running Java 9 and then attempt to deserialize it on a Java 8 system. Also consider the vice-versa situation.
One more situation that I can think of is String data being transmitted across Java 8 and Java 9 systems using RMI or JMS.
How could these scenarios possibly work? Are all the methods handling String being upgraded to handle such scenarios?
Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory. This mechanism is used to persist the object. The byte stream created is platform independent.
The proposal is that serialization be removed in a phased manner, as follows. In a JDK 7 update, possibly update 6, the Serializable , ObjectInputStream , ObjectOutputStream , and associated classes in the java.io package will be deprecated.
For serializing the object, we call the writeObject() method of ObjectOutputStream class, and for deserialization we call the readObject() method of ObjectInputStream class. We must have to implement the Serializable interface for serializing the object.
Deserialization is the process of reconstructing a data structure or object from a series of bytes or a string in order to instantiate the object for consumption. This is the reverse process of serialization, i.e., converting a data structure or object into a series of bytes for storage or transmission across devices.
While it is true that the in-memory representation of String
has changed, its Serializable
representation has not. Have you actually tried to serialize a String
in Java 9 and deserialize it back in Java 8? I don't think you'll run into any problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With