I know this might be quite old question, but I am confused. So far as I know, with the Reflection API, we can serialize instances, then why does java need an empty interface like Serializable ? I read from an article that this is designed for safety reasons, i.e., only instances marked Serializable can be serialized. if this is so important however, I see in many frameworks, like kafka, the instances don't have to implement Serializable. won't they encounter safety occasions ? what is the difference ?
Asked
Active
Viewed 15 times
0
-
Because some things you don't want to serialize, such as passwords. – user207421 May 23 '22 at 05:57
-
Kafka has its own Serializer class. **That is mandated**. Strings, Integers, etc have known byte formats. You shouldn't use Java Serializable types as messages, instead use cross language RPC formats like JSON, AVRO, Protobuf, etc – OneCricketeer May 23 '22 at 12:35