Stream Unique Identifiers

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: java.io.InvalidClassException: 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(RMIServer_Stub.java:40)at RMIClient.main(RMIClient.java:7)

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:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several