Description
Unsafe can be used to significantly speed up serialization process, if a JDK implementation supports java.misc.Unsafe properly. Most JDKs running on PCs support it. Some platforms like Android lack a proper support for Unsafe yet.
There are two possibilities to use Unsafe for serialization:
1) Very quick access to the fields of objects. It is way faster than with the reflection-based approach using Field.get/set
2) Input and Output streams can be using Unsafe to perform very quick input/output.
3) More over, Unsafe makes it possible to serialize to/deserialize from off-heap memory directly and very quickly, without any intermediate buffers allocated on heap. There is virtually no overhead compared to the usual byte arrays.