Search in sources :

Example 1 with ArraysAsListSerializer

use of de.javakaffee.kryoserializers.ArraysAsListSerializer in project Paper by pilgr.

the class DbStoragePlainFile method createKryoInstance.

private Kryo createKryoInstance() {
    Kryo kryo = new Kryo();
    kryo.register(PaperTable.class);
    kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
    kryo.setReferences(false);
    // Serialize Arrays$ArrayList
    //noinspection ArraysAsListWithZeroOrOneArgument
    kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    SynchronizedCollectionsSerializer.registerSerializers(kryo);
    // Serialize inner AbstractList$SubAbstractListRandomAccess
    kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(), new NoArgCollectionSerializer());
    // Serialize AbstractList$SubAbstractList
    kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(), new NoArgCollectionSerializer());
    // To keep backward compatibility don't change the order of serializers above
    // UUID support
    kryo.register(UUID.class, new UUIDSerializer());
    for (Class<?> clazz : mCustomSerializers.keySet()) kryo.register(clazz, mCustomSerializers.get(clazz));
    kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    return kryo;
}
Also used : NoArgCollectionSerializer(io.paperdb.serializer.NoArgCollectionSerializer) StdInstantiatorStrategy(org.objenesis.strategy.StdInstantiatorStrategy) UUIDSerializer(de.javakaffee.kryoserializers.UUIDSerializer) ArraysAsListSerializer(de.javakaffee.kryoserializers.ArraysAsListSerializer) Kryo(com.esotericsoftware.kryo.Kryo)

Example 2 with ArraysAsListSerializer

use of de.javakaffee.kryoserializers.ArraysAsListSerializer in project quasar by puniverse.

the class KryoUtil method registerCommonClasses.

public static void registerCommonClasses(Kryo kryo) {
    kryo.register(boolean[].class);
    kryo.register(byte[].class);
    kryo.register(short[].class);
    kryo.register(char[].class);
    kryo.register(int[].class);
    kryo.register(float[].class);
    kryo.register(long[].class);
    kryo.register(double[].class);
    kryo.register(String[].class);
    kryo.register(int[][].class);
    kryo.register(java.util.ArrayList.class);
    kryo.register(java.util.LinkedList.class);
    kryo.register(java.util.HashMap.class);
    kryo.register(java.util.LinkedHashMap.class);
    kryo.register(java.util.TreeMap.class);
    kryo.register(java.util.EnumMap.class);
    kryo.register(java.util.HashSet.class);
    kryo.register(java.util.TreeSet.class);
    kryo.register(java.util.EnumSet.class);
    kryo.register(java.util.Arrays.asList("").getClass(), new ArraysAsListSerializer());
    kryo.register(java.util.Collections.newSetFromMap(new java.util.HashMap()).getClass(), new CollectionsSetFromMapSerializer());
    //        kryo.register(java.util.Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer());
    //        kryo.register(java.util.Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer());
    //        kryo.register(java.util.Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer());
    //        kryo.register(java.util.Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer());
    //        kryo.register(java.util.Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer());
    //        kryo.register(java.util.Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer());
    kryo.register(java.util.GregorianCalendar.class, new GregorianCalendarSerializer());
    kryo.register(java.lang.reflect.InvocationHandler.class, new JdkProxySerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    SynchronizedCollectionsSerializer.registerSerializers(kryo);
    kryo.addDefaultSerializer(Externalizable.class, new ExternalizableKryoSerializer());
    kryo.addDefaultSerializer(java.lang.ref.Reference.class, new ReferenceSerializer());
}
Also used : JdkProxySerializer(de.javakaffee.kryoserializers.JdkProxySerializer) ArraysAsListSerializer(de.javakaffee.kryoserializers.ArraysAsListSerializer) GregorianCalendarSerializer(de.javakaffee.kryoserializers.GregorianCalendarSerializer)

Aggregations

ArraysAsListSerializer (de.javakaffee.kryoserializers.ArraysAsListSerializer)2 Kryo (com.esotericsoftware.kryo.Kryo)1 GregorianCalendarSerializer (de.javakaffee.kryoserializers.GregorianCalendarSerializer)1 JdkProxySerializer (de.javakaffee.kryoserializers.JdkProxySerializer)1 UUIDSerializer (de.javakaffee.kryoserializers.UUIDSerializer)1 NoArgCollectionSerializer (io.paperdb.serializer.NoArgCollectionSerializer)1 StdInstantiatorStrategy (org.objenesis.strategy.StdInstantiatorStrategy)1