facebook

[Closed] serial/VersionUID warning

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #265668 Reply

    maximuszen
    Member

    serializable class SERVLETNAME does not declare a static final serial/VersionUID field of type long

    I get this warning. Can someone tell me what it means or how I can get rid of it.

    #265717 Reply

    Scott Anderson
    Participant

    It means you have a serializable class but have not declared the serialVersionUID field.
    See: http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html

    #265719 Reply

    maximuszen
    Member

    Thank you for your reply. I read the documentation. I am a novice so what I understand is that it is an internal mechanism to maintain serial objects. So I should explicity declare

    ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;

    I can make ANY-ACCESS-MODIFIER public or private. I’m not sure why this doesn’t make a difference. This is going to be a simpleton question. So if you assign a static value for this object, how does the JVM maintain uniqueness of the various objects. Does it not better because it is a servlet?

    The number can I assume I can assign any random value to various my servlets because this is where I can the warning.

    Would very much appreciate your comments.

    John

    #266036 Reply

    jhm
    Member

    The easiest way for fixing the “missing-serial/VersionUID” warning is using Eclipse Quick-Fix (Ctrl-1). I suggest using the “Add generated serial version ID”.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: [Closed] serial/VersionUID warning

You must be logged in to post in the forum log in