Re: serialVersionUID in autogenerated classes?

From: Ryan Holmes (rya..yperstep.com)
Date: Wed Feb 15 2006 - 02:34:43 EST

  • Next message: Dave Merrin: "Cayenne Modeler class generation"

    Cris Daniluk wrote:
    >> SerialVersionUID's do not change each time you compile a class - they
    >> are calculated by the JVM based on various aspects of the class that may
    >> affect it's serialization compatibility. So, if you don't change a class
    >> and you're using the same JVM, the class's calculated serialVersionUID
    >> will not change between builds.
    >>
    >>
    > Nobody said they would.... though there are lots of bugs in past JDKs
    > where it could happen.
    >
    I was responding to your statement that a calculated serialVersionUID
    will change every time a class is recompiled:

    In general, you don't need a serialVersionUID.. however if
    you don't have one, it will change every time the class is recompiled
    (and further change between certain JVMs, but that's another issue).

    >
    >> If you declare a serialVersionUID, you should do it in your domain
    >> classes rather than on Cayenne's generated superclasses
    >>
    >
    > Actually, every class in the ancestry must have a matching
    > serialVersionUID, not just the base class. Thus, if the Cayenne
    > classes changed in the modeler, you would have an incompatibility
    > regardless of the serialVersionUID in the wrapper class. In fact if
    > your wrappers are empty, the serialVersionUID you declare there is
    > utterly meaningless.
    >
    > It is pretty easy to demonstrate this..
    >
    >
    Yes, absolutely - it's been awhile since I've had to worry about
    serialization compatibility. I guess this goes to your point about it
    being a complex subject ;)

    -Ryan



    This archive was generated by hypermail 2.0.0 : Wed Feb 15 2006 - 02:34:49 EST