IntelliJ IDEA: serialVersionUID generator

Cleaning up code I launched serialver to create serialVersionUIDs for some serializable classes. Wondering why IntelliJ IDEA did not seem to provide a generator for UIDs, I browsed the code inspection settings and it turns out that there actually is one – but it is disabled by default. To use it, go to

Settings -> Errors -> Serialization issues -> Serializable class without ‘serialVersionUID’

When editing a Serializable class without a serialVersionUID field set, IDEA now displays a warning and provides a Quickfix (Alt+Enter) to generate one.

13 Comments »

  1. Thanks for the tip! I was wondering the same thing myself — ie why do I have to go to serialver to do that!

    cheers,

    dave

  2. Chas said

    Thank you!

  3. Elwyn said

    Thanks for that. Time saved!

  4. Rob said

    Thanks!

  5. Artyom said

    Great tip, thanks a lot!

  6. Chess said

    Thanks a lot – plugins are not working @Idea 8.1, that helped.

  7. Amar said

    Great tip. I was just woundering why the GeneratesSerialVersionUID plugin was not working and thought of updating the code. this will save a lot of my time.

  8. anony said

    I do not find it helpful to initialize a serialVersionId with a 0 value. So, quick fix initialize version id is not very helpful.

    • anony said

      I do not find it helpful to initialize a serialVersionId with a 0 value. So, quick fix initialize version id is not very helpful.

      -> I had a manual typed serialVersionId field in my class. If you delete the field, quick fix on class will generate new field with valid serial version id. That fixed my prob.

  9. Daniel Lichtenberger said

    If ‘quick fix’ initializes serialVersionId with 0, something is broken in your version of IDEA.

  10. Dmitry said

    In the Intellij Idea 9.0 the sequence of actions has been changed.
    settings->Inspections->Serializable class without ‘serialVersionUID’

    • Dustin said

      Note that in IntelliJ 9, you need to have the Inspection Gadgets plugin installed for this inspection to be available.

  11. you said

    (Y) Thank you

RSS feed for comments on this post · TrackBack URI

Leave a reply to you Cancel reply