Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8485693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:43:11+00:00 2026-06-10T20:43:11+00:00

It has baffled me from the launch of the Serializable interface why I have

  • 0

It has baffled me from the launch of the Serializable interface why I have to incorporate this field in all of my classes. I understand that this interface needs a unique identifier to mark the class but why cant they generate this at run-time. For instance they could generate it using an MD5 hash of the fully-qualified class name or a similar methodology used to handle duplicates in their rare occurrence (Which is, I’m sure, what eclipse does when asked to generate the id anyway).

So what I’m asking (no this post isn’t just a rant against the standard library) is exactly how the serialization field is used by the framework?

The reason I would like to know because I am going to try to create an Aspect (in AspectJ or other language) that will add the serialVersionUID field using an MD5 hash and is able to handle collisions in a way that is acceptable to the API.

I will post the results if I can get it working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:43:13+00:00Added an answer on June 10, 2026 at 8:43 pm

    There is no requirement to have the serialVersionUID field. If you don’t provide one, Java will generate one based on the fields and methods of your class.

    The reason why you might want to specify serialVersionUID is to prevent the value from changing when methods are changed, which doesn’t impact the serialized binary. Consider the class:

    public class Person implements Serializable {
        private String name;
        public String getName() {
            return name;
        }
    }
    

    No serialVersionUID was specified. If you run serialver Person it returns:

    Person:    static final long serialVersionUID = 3793453319058452486L;
    

    Now you decide to add a method but leave the fields the same.

    public class Person implements Serializable {
        private String name;
        public String getName() {
            return name;
        }
        public Object foo() {
            return "bar";
        }
    }
    

    The serialized binary is still fully compatible with the old version, but the serialVersionUID is different:

    Person:    static final long serialVersionUID = -6188734029437600310L;
    

    With a different serialVersionUID, deserializing will result in a serialVersionUID mismatch error. The workaround is declare your own serialVersionUID by setting it to any value (I set it 1L), and changing it whenever the fields have changed.

    Also see this related question “What is a serialVersionUID and why should I use it?” for a more detailed discussion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day all; I am not sure what has changed to prevent this from
This one has me utterly baffled... I have a very simple input model, with
This has me baffled. I need to copy the Bitmap from one ImageView into
This has always baffled me, I understand the concept of pretty URLs yet cannot
this has baffled me for a couple of hours now. Why do i get
This question has baffled myself and my cohorts. In the program I had written
It has always baffled me that if a folder has read and write permissions,
This issue has me baffled, it's affecting a single user (to my knowledge) and
I was baffled today when someone mentioned on a group that Javascript has evolved
Has anyone successfully tried minifying AND concatenating all the jqGrid locale files so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.