The difference between Java serialization and Hessian serialization

Source: Internet
Author: User

Java Serialization:

Java serialization serializes all the metadata and business data of the object class to be serialized into a byte stream, and it serializes everything on the entire inheritance relationship . The byte stream that it serializes is a complete description of the object's structure to the content, contains all the information, and is therefore less efficient and the byte stream is relatively large . But because it does serialize everything , it can be said that everything can be transferred and therefore more usable and reliable .


Hession Serialization:

Its implementation mechanism is focused on the data, with a simple method of type information . Just like an Integer a = 1,hessian is serialized into a stream like I 1, i means that int or integer,1 is the data content. And for complex objects, through the reflection mechanism of Java, Hessian all the properties of the object as a map to serialize , producing similar m className propertyName1 I 1 PropertyName S StringValue (presumably, exactly, forget) such a stream contains the basic type description and data content. In the serialization process, if an object appears before, Hessian inserts a block such as R index to represent a reference location, eliminating the time to serialize and deserialize again . The cost of doing this is that Hessian needs to do different things for different types (so Hessian is lazy and does not support short), and special handling is required for some special objects (such as Stacktraceelement). At the same time, there are some inconsistencies in some situations, such as a map obtained through COLLECTIONS.SYNCHRONIZEDMAP, because it is not going deep into the internal serialization of the implementation.

The difference between Java serialization and Hessian serialization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.