RuedigerMoeller / fast-serialization

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

What does registerClass do? #348

Open debraj-manna opened 9 months ago

debraj-manna commented 9 months ago

Hi

The javadoc of registerClass states like below

 /**
     *
     * Preregister a class (use at init time). This avoids having to write class names.
     * Its a very simple and effective optimization (frequently > 2 times faster for small objects).
     *
     * Read and write side need to have classes preregistered in the exact same order.
     *
     * The list does not have to be complete. Just add your most frequently serialized classes here
     * to get significant gains in speed and smaller serialized representation size.
     *
     */

Let's say on the write side A.class is registered. How is deserialization going to behave in the below cases

  1. On the read side A.class is not registered and instead some other class, B.class is registered. Will the read side break in this case during deserialization?
  2. On the read side no class is registered. Will read side work?
  3. On the read side FST is not used and JDK serialization is used. Will the read side break in this case?