Search code examples
javaserializationjava-8deserializationdb4o

Is db4o Java 8 compatible?


Have side project that is using db4o. It's doesn't work with JVM 8 (on deserialising getting Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.xxx.yyy.version to com.db4o.reflect.generic.GenericObject).

  1. Is it possible to fix it for JVM 8 (and yes, I know that db4o is dead)?
  2. What to use instead of db4o for JVM version independent serialisation/de-serialization?

Solution

  • Quick answer: Db4o IS compliant Java 8. It was hibernate proxy issue (Javassist and dynamic classes) :(

    Update 07/20/15: Not sure that db4o is 100% correctly works under JVM 8. We have a strange test case that we cannot explain (see below). At the same time native Java serialisation works correctly (but db4o doesn't).

    Full answer: If someone need details, this issue appears in Hibernate 4.3 (in previous versions everything works as expected). Unfortunately, I didn't find correct solution. Quick and dirty workaround is to skip problem fields from exporting to db4o (via transient keyword).

    Update 07/30/15: Found a solution (the issue appears in Javassist 1.8):

    ProxyFactory.nameGenerator = new JavassitBackwardCompatibleNamingGenerator();
    
    public class JavassitBackwardCompatibleNamingGenerator implements UniqueName{
        private static int counter = 0;
        @Override
        public String get(String classname) {
            return classname + "_$$_javassist_" + counter++;
        }
    }