What is the serialVersionUID?

Home Forums PeerfactSim Forum What is the serialVersionUID?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #771
    Same Diffr

    In Java files like “JoinMsg.java” (package: org.peerfact.impl.overlay.dht.pastry.base.messages) I find a variable:
    private static final long serialVersionUID = -7372693081066186219L;

    What is the meaning / use of this variable?

    Reason of this question:
    I want to add some new message types to the message package of Pastry.

    Does every new message type I create need such a serialVersionUID?
    If yes, how should I choose / determine it’s value?

    Best regards

    Philipp Giesen

    It’s used for serialization of a class object. StackOverflow offers a
    good explanation: http://stackoverflow.com/a/285809/2674385

    You can also look into the docs of java.io.Serializable to get a grasp
    on the basics of Serialization in Java.

    Short answers: It is highly recommended you do implement it.


    > You received this message because you are subscribed to the Google Groups
    > “PeerfactSim.KOM” group.
    > To unsubscribe from this group and stop receiving emails from it, send an
    > email to peerfactsim-k…@googlegroups.com.
    > For more options, visit https://groups.google.com/groups/opt_out.

    Same Diffr

    Thank you for your answer, Philipp.

    As I understood, I definitely need to assign a serialVersionUID for every message type I am adding to the source code. My question is now: How?

    What do I have to keep in mind when assigning it? Do I have to avoid declaring one that is already existing in some code of the simulator? How did the developers of the simulator come up with such huge long (datatype) numbers? Can I just use a random long number with the same length as one existing serialVersionUID?

    Best regards

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Comments are closed.