Stream Unique Identifiers

While attempting to deserialize (or unmarshal) a serialized object instance, you may generate an exception with a message similar to:

 java.rmi.UnmarshalException: Error unmarshaling return; nested exception is: RMIParm; Local class not compatible: stream classdesc serialVersionUID=9468404698496832181 local class serialVersionUID=7528655624442771181at java.lang.Throwable.(Compiled Code)at java.rmi.UnmarshalException.(Compiled Code)at RMIServer_Stub.getParm( RMIClient.main(

This error occurs as a result of the class that was serialized and deserialized having been changed at some point. For example, it can occur when a server attempts to return an instance of an object to a client through Remote Method Invocation (RMI) while the client and server have different definitions of the class. This commonly occurs and can take place when the class is modified and recompiled on the client after being copied to the server. Another scenario might involve writing an object instance to disk, changing the source code for the class and recompiling it, then attempting to read the class instance stored in the disk file. In these cases, the reader’s version of the class definition is different from that of the writer, and the exception indicates that these are potentially incompatible versions of the same class.

However, it may be that the changes made to the class should not cause older versions to break, such as when new methods or variables are added. In this case, you can avoid problems unmarshalling old class instances by explicitly defining the Stream Unique Identifier (SUID). The SUID is nothing more than a value (usually the hash value for the class definition) that uniquely identifies a class definition. You can determine the SUID for a given serializable class by using the serialver utility included with the Java Development Kit (JDK):

 serialver myclass

This will produce output similar to:

 myclass: static final long serialVersionUID = -3920827908241085518L;

Adding this statement to the class you wish to modify will allow you to successfully deserialize or unmarshal modified versions of the class. For more information, see the section on the versioning of serializable objects in the Object Serialization Specification document that is included with the JDK.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS