I am quite familiar with java, but somehow serialization was always beyond my responsibilities.
Java9 introduced compact strings feature, so characters in strings are always backed into byte[]
, not char[]
array. This is quite good from memory perspective, allowing Latin1 strings to occupy (roughly) x2 less memory. Nevertheless, this is kinda unclear for me from serialization perspective. Let me explain:
Let us have a serializable class:
public class Person implements Serializable
{
public String name;
public String surname;
public Person(String name, String surname)
{
this.name = name;
this.surname = surname;
}
}
Now if we'll serialize the created person into binary (I won't copy-paste the code, but this is how it is usually being done, we'll have either binary file or byte array.
Now, the question: If we'll have a new Person("John", "Doe")
and a new Person("Jön", "Döe")
being serialized using java9+, will they be correctly deserialized in earlier releases of java (let's say java8)? How could java handle it if can? Thanks.