How do generate this value in IntelliJ IDEA?
I go to Settings -> Errors -> Serialization issues -> Serializable class without ‘serialVersionUID’, but it still doesn't show me the warning. My class PKladrBuilding parent implements interface Serializable.
Part of the code:
public class PKladrBuilding extends PRQObject
public abstract class PRQObject extends PObject
public abstract class PObject implements Serializable
I am not sure if you have an old version of IntelliJ IDEA, but if I go to menu File → Settings... → Inspections → Serialization issues → Serializable class without 'serialVersionUID'` enabled, the class you provide give me warnings.
If I try the first class I see:
BTW: It didn't show me a warning until I added
{ }
to the end of each class to fix the compile error.After spending some time on Serialization, I find that, we should not generate
serialVersionUID
with some random value, we should give it a meaningful value.Here is a details comment on this. I am coping the comment here.
Hope this helps. Good luck.
I am using Android Studio 2.1 and I have better consistency of getting the lightbulb by clicking on the class Name and hover over it for a second.
If you want to add the absent serialVersionUID for a bunch of files, IntelliJ IDEA may not work very well. I come up some simple script to fulfill this goal with ease:
You save this script, say as
add_serialVersionUID.sh
in your~/bin
folder. Then you run it in the root directory of your Maven or Gradle project like:This .lst includes the list of Java files to add the serialVersionUID in the following format:
This script uses the JDK serialVer tool. It is ideal for a situation when you want to amend a huge number of classes which had no serialVersionUID set in the first place while maintain the compatibility with the old classes.