/** * Creates a Kryo instance. * * @return Kryo instance */ @Override public Kryo create() { log.trace("Creating Kryo instance for {}", this); Kryo kryo = new Kryo(); kryo.setRegistrationRequired(registrationRequired); // If compatible serialization is enabled, override the default serializer. if (compatible) { kryo.setDefaultSerializer(CompatibleFieldSerializer::new); } // TODO rethink whether we want to use StdInstantiatorStrategy kryo.setInstantiatorStrategy( new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); for (RegistrationBlock block : registeredBlocks) { int id = block.begin(); if (id == FLOATING_ID) { id = kryo.getNextRegistrationId(); } for (Pair<Class<?>[], Serializer<?>> entry : block.types()) { register(kryo, entry.getLeft(), entry.getRight(), id++); } } return kryo; }