Field Type Meta
Field type meta configuration controls whether type information is written during serialization for struct fields. This is essential for supporting polymorphism where the actual runtime type may differ from the declared field type.
Overview
When serializing a struct field, Fory needs to determine whether to write type metadata:
- Static typing: Use the declared field type's serializer directly (no type info written)
- Dynamic typing: Write type information to support runtime subtypes
When Type Meta Is Needed
Type metadata is required when:
- Interface/abstract fields: The declared type is abstract, so concrete type must be recorded
- Polymorphic fields: The runtime type may be a subclass of the declared type
- Cross-language compatibility: When the receiver needs type information to deserialize correctly
Type metadata is NOT needed when:
- Final/concrete types: The declared type is final/sealed and cannot be subclassed
- Primitive types: Type is known at compile time
- Performance optimization: When you know the runtime type always matches the declared type