Reputation: 289
Can you safely deserialize with OpenJDK some binary data that we got by serializing something with Oracle JDK? (and vice-versa)
Let’s assume the java version is the same (and that the class code is available, and is the same, in both stages).
Is the exact way Oracle JVM serializes objects considered public information?
Upvotes: 4
Views: 905
Reputation: 33
I will say it is not entirely safe. In my Android app, I can not deserialize data on an Android 7 device which has been serialized on an Android 6 device. Apparently, Google switched to OpenJDK in Android 7. The error I get is:
java.io.StreamCorruptedException: invalid type code: 71
This problem was reported here in a similar fashion
This poses quite a problem since my app sends serialized data over the internet and it will not be compatible if it runs on both Android 6(or lower) and Android 7.
Upvotes: 1
Reputation: 3097
To expand on comments from @morgano, @RealSkeptic and @EJP (to whom credit should be given): yes, Java Object serialization is directed by an official specification, which is public, so any JVM implementation that does serialization should conform to it, or not be called a JVM.
Upvotes: 2