Questions tagged [serialversionuid]

`serialVersionUID` is an optional attribute of Java classes to indicate the standard serialization/deserialization format version. Used to detect if a serialized object is incompatible with the deserialization process/class.

Documented in java.io.Serializable:

The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long:

ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;
122 questions
0
votes
0 answers

Serialization And Deserialization Error : local class incompatible: stream classdesc serialVersionUID = , local class serialVersionUID = -

Let's say I have Class A which is implementing Serialization interface. and class is used so many places. (Services, micro-services). Now I have added one attribute to the class A, and getting Error: local class incompatible: stream classdesc…
user2888996
  • 417
  • 8
  • 20
0
votes
2 answers

necessity of serialVersionUID in Kotlin when developing for Android

I had an internal discussion on the requirements for a serialVersionUID when coding in Kotlin, specifically for the Android platform. In Java we always added it, since Android Studio makes it real easy. However, there is no help there for Kotlin…
Michiel
  • 3
  • 2
0
votes
1 answer

How to prevent the auto-generation of comments just for quick-fixing the serialVersionUID warning?

This Eclipse question is a response to "Getting rid of the comment above eclipse generated serialVersionUID," but so far the single answer (which addresses this linked question, and is accepted) applies to all comments. But my question will be more…
0
votes
1 answer

InvalidClassException in a non edited class

I'm getting this error : ERROR com.calyon.espm.businessdelegate.translation.InCacheTranslationDelegateImpl 36 - org.springframework.remoting.RemoteAccessException: Cannot access HTTP invoker remote service at [http://[url]/reference.espmservice];…
Radhwen
  • 232
  • 4
  • 15
0
votes
0 answers

Is it possible to indicate several destination directories to Javac?

I wrote a Java class, let A, which must be compiled once and saved in several directories (let Y, and Z). Therefore, the compiled files would have the same SerialVersionUID (I need it), in any directory (Y and Z). I tried to make use of javac A.java…
JarsOfJam-Scheduler
  • 2,809
  • 3
  • 31
  • 70
0
votes
2 answers

Does serialVersionUID generation in Eclipse use serialver?

Eclipse IDE allows generation of random serialVersionUID. On the other hand, there is a tool in JDK, serialver, which is designed for the purpose. Any idea if Eclipse actually invokes serialver behind the curtains?
Mateva
  • 786
  • 1
  • 8
  • 27
0
votes
2 answers

SerialVersion UID Java - How SerialVersionUID work?

Hello I've one question about SerialVersionUID in Java. If I generate a SerialVersionUID for class A, 2 instances of A have the same SerialVersion about class and another unique Serial for the object, different about object1 and object2? Or how? I…
Antonio1996
  • 736
  • 2
  • 7
  • 22
0
votes
2 answers

Java backward-compatibility: how readObject() read same classname objects with different serialVersionUID?

This socket will keep receiving some old objects and new objects with same name. However, if I used readObject directly, it will throws fatal exception. Some of us would suggest to ignore old object or change the old object code. This is not…
Pika
  • 507
  • 1
  • 6
  • 16
0
votes
1 answer

serialVersionUID in the swagger-codegen-maven-plugin generated code

I'm using swagger-codegen-2.1.6 and successfully generated serialized model classes through swagger-codegen-maven-plugin using serializableModel configOptions. However, I don't see the serialVersionUID added to the classes, neither I can find any…
sahaS
  • 41
  • 1
  • 5
0
votes
2 answers

generate serialVersionUID automatically in intellij stopped working

I've managed before to generate serialVersionUID automatically in IntelliJ IDEA by both installing the plugin GenerateSerialVersionUID and enabling the checkbox in settings - code - inspection like prior answers to this questions said. I can't let…
Joe
  • 1
  • 1
  • 2
0
votes
2 answers

java.io.InvalidClassException while deserializing object after some modification in a java class

Why failed to deserialized however I have serialized this Container class using serialVersionUID = 75264711556228L; public class Container implements Serializable { private static final long serialVersionUID = 75264711556228L; public…
Dinanath Parit
  • 165
  • 3
  • 4
0
votes
1 answer

how to fix serialVersionUID not equal exception in the same class?

java.io.InvalidClassException: com.sungymobile.cache.resource.ResourceCacheLoader$ResourceCache; local class incompatible: stream classdesc serialVersionUID = 6381106003702990139, local class serialVersionUID = 3777451853403693248
side
  • 209
  • 2
  • 9
0
votes
0 answers

What is the most appropriate access modifier for serialVersionUID

Short version: What is the MOST appropriate access modifier for serialVersionUID? Eclipse defaults to private, but are there anything wrong with setting it to something more visible? Background: I'm writing a library that heavily extends ArrayList.…
HesNotTheStig
  • 549
  • 1
  • 4
  • 9
0
votes
1 answer

Versioning and Serialization

So this is a question about Serialization and Versioning. I have a program that is a Music database that stores sheet music with Name, Composer, ... I serialize each song to a hidden folder so that the user can reload the database at next launch.…
0
votes
1 answer

Serialization serialVersionUID issue

Clinet runs in JVM A , Server Runs in JVM B. There are all EJB Call from client to server. Now any of the 2 objects I expect in Client side. Array of LoanDocument or BusinessServicesException public interface LoanViewerServicesLocal extends…
1 2 3
8 9