RuedigerMoeller / fast-serialization

FST: fast java serialization drop in-replacement
Apache License 2.0
1.59k stars 247 forks source link

Register Class Order #213

Open caglartolgatetik opened 7 years ago

caglartolgatetik commented 7 years ago

Hi, I register all Serializable classes with reflection and it works good on both serialize and deserialize. If I remove one of that classes or add a new one, it gives exceptions. I know it should have same register order. As much as, I know Kryo has a registration method, so you can give id for each registered class. I couldn't find but do you have such a method or any plan to implement such a mechanism or any suggestion for solution?

Thanks

RuedigerMoeller commented 7 years ago

it would be possible using e.g. annotations, however in order to avoid backward compat issues you would have to track id collisions manually. A simpler solution would be the ability to "reserve" an Id, so instead of removing a class you just put in an incrementIdCount() or so (or just give null as argument). registering via reflection is dangerous reagrding proper order long term ..

RuedigerMoeller commented 7 years ago

wait what: it's already possible FSTConfiguration::getClassRegistry().registerClass( Class c, int code, FSTConfiguration conf). Warning: