auto switch java serial and kryo