Wednesday 15 June 2011

serialization - Should a serialized Java object always be represented by the same sequence of bytes each time is it serialized? -


For example, if the object frequency was serialized (resulting in 'byte [] BS1') then Is re-ordering (which means 'byte [] BS2'), 'BS1' and 'BS2' should be of the same length and there will be only one bytes? If not, then why not?

To avoid ambiguity, I should say that two serialization of the same object (not the same example) - the same thread in the second millisecond of each other, on the same JVM - one (mutateable) A method was passed before the object, after one.

Note that the object is not even sorted, deserialized , and then reordered - it is being sorted only twice, besides the class of the object ' There is nothing but clever '; It's just a simple, total POJO.

I am using serialized bytes to use as an ad hoc examination so that it can be detected that the object has been changed within the method. However, I'm seeing an example where the object has not changed its position clearly - yet one byte is different from the other.

I was thinking - and it was just a perception - be like this. Is there something that can not be done?

Appendix:

Besides, there is no excuse for example code to clarify the point. Currently it is a small piece of embedded code in a large system. If necessary, I will try and take out a small, dynamic performance. I wonder if there was a basic problem with my belief , and so if someone could explain why the assumption is wrong.

This can not always be a sequence of bytes that is generated through serialization. For example, in the order in which a set serializes its elements, it is not guaranteed to be continuous, even if we are talking about an example.

No comments:

Post a Comment