3

My app uses http://prevayler.org/ for persistence, piggybacking Java Object serialization. After upgrade to Android 7.0 (Nougat) users cannot open their data, since the deserialization does not work any more:

java.io.StreamCorruptedException: invalid type code: 71
  at java.io.ObjectInputStream.readString(ObjectInputStream.java:1647)
  at java.io.ObjectInputStream.readEnum(ObjectInputStream.java:1737)
  ...
  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
  at org.prevayler.foundation.serialization.JavaSerializer.readObject(JavaSerializer.java:34)
  ...
  at org.prevayler.PrevaylerFactory.snapshotManager(PrevaylerFactory.java:368)
  at org.prevayler.PrevaylerFactory.create(PrevaylerFactory.java:316)
  at com.tennismath.prevayler.PrevaylerServiceImpl.getSystemPrevayler(PrevaylerServiceImpl.java:51)

While deserializing an enum, the OpenJDK routine reads the unexpected byte value of "71" and throws the exception, as it can be seen from the source code: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/io/ObjectInputStream.java#ObjectInputStream.readString%28boolean%29

I have the following ideas:

  1. Set up a migration server, which would run both Harmony and OpenJDK processes, which would perform data migration.
  2. Hack the binary format and fix the enums serialization (assumed the it is the only one issue, which I doubt)
  3. Hack the deserialization with AspectJ

All these choices seem to be either an overkill or unsatisfying. Before I start hacking the binaries, maybe anybody has a better idea of what can be done to deserialize the old data with the new runtime? Thank you.

Ilya Shinkarenko
  • 2,134
  • 18
  • 35
  • 2
    Sure, I should have used Prevayler' XML serializer instead. But who could have predicted that Android would switch its JVM. And other than that I have discovered that Apache Harmony volates the specification with regards to enum serialization. – Ilya Shinkarenko Oct 10 '16 at 07:16

0 Answers0