0

I am trying to use the Kryo library to perform deep copying of objects, but I have a little problem. I'd like to deep-copy an object without transient variables. I know that I can use setCopyTransient(false) for FieldSerializer like so:

FieldSerializer<?> playerSerializer = new FieldSerializer<Player>(kryo, Player.class);
playerSerializer.setCopyTransient(false);
kryo.register(Player.class, playerSerializer);

but I would have to set a new FieldSerializer for every class. Can I get somehow a default FieldSerilizer from Kryo and set there setCopyTransient(false)? I tried something like this and similar solutions, but it doesn't do anything:

FieldSerializer<?> serilizer = (FieldSerializer<?>) kryo.getDefaultSerializer(FieldSerializer.class);
serilizer.setCopyTransient(false);
MustangXY
  • 358
  • 2
  • 16
Sabriael
  • 332
  • 1
  • 6
  • 14

1 Answers1

0

Which version of kryo you are using. I am using 3.0.0 and my transient fields are not serialized.

Jags
  • 799
  • 7
  • 19
  • I am using kryo version 3.0.3. Are you using kryo for deep-copy (`kryo.copy()` method)? Copying does not serialize to bytes and back. In normal serialization transient fields are omitted, but in cooping there are not. – Sabriael Sep 30 '15 at 18:18
  • @Sabriael No. I am using it to stream out data over network. I think copy may be doing it intentionally. – Jags Oct 01 '15 at 20:21