Java vs C# Serialization

Discussion in 'Java' started by Ray Mitchell, Nov 13, 2003.

  1. Ray Mitchell

    Ray Mitchell Guest

    Hello,

    I have two Java applications that exchange serialized objects. Although I
    would like to ultimately convert both to C# it's a pretty monumental task,
    especially for someone just learning both langauges. I thought it might be
    more reasonable to start with simply converting the simpler one of the two
    and getting it to work. I have used Microsoft's free Java to C# converter
    to convert most of the code, but of course I must complete some of the
    conversions manually. I have this basic concern, however: Will the
    serialization done in C# be the same as that done in Java? Also, do all
    Java compilers serialize the same way for the same source code?

    Thanks,
    Ray Mitchell
    Ray Mitchell, Nov 13, 2003
    #1
    1. Advertising

  2. Mike Schilling wrote:

    >>Also, do all
    >>Java compilers serialize the same way for the same source code?

    >
    > Yes. Java serialization is defined precisely.
    >


    However the calculation of the serialVersionUID is not so well defined.
    The problem is that the calculation includes synthetic members whose
    existence and name can be compiler dependent.

    Mark Thornton
    Mark Thornton, Nov 15, 2003
    #2
    1. Advertising

  3. "Mark Thornton" <> wrote in message
    news:fjotb.162$...
    > Mike Schilling wrote:
    >
    > >>Also, do all
    > >>Java compilers serialize the same way for the same source code?

    > >
    > > Yes. Java serialization is defined precisely.
    > >

    >
    > However the calculation of the serialVersionUID is not so well defined.
    > The problem is that the calculation includes synthetic members whose
    > existence and name can be compiler dependent.
    >


    Ouch! That can be a problem even across different versions of the same
    compiler.

    IMHO, if you're going to serialize a class, you should define
    serialVersionUID explicitly. That allows you to control if and when
    persistent compatibility is broken.
    Mike Schilling, Nov 19, 2003
    #3
  4. Mike Schilling wrote:
    > "Mark Thornton" <> wrote in message
    > news:fjotb.162$...
    >
    >>Mike Schilling wrote:
    >>
    >>
    >>>>Also, do all
    >>>>Java compilers serialize the same way for the same source code?
    >>>
    >>>Yes. Java serialization is defined precisely.
    >>>

    >>
    >>However the calculation of the serialVersionUID is not so well defined.
    >>The problem is that the calculation includes synthetic members whose
    >>existence and name can be compiler dependent.
    >>

    >
    >
    > Ouch! That can be a problem even across different versions of the same
    > compiler.
    >
    > IMHO, if you're going to serialize a class, you should define
    > serialVersionUID explicitly. That allows you to control if and when
    > persistent compatibility is broken.
    >
    >


    I agree, explicitly defining serialVersionUID is now all but essential.
    The documentation and tutorials should be updated to reflect this. The
    version of Java (1.5) will introduce quite a few more synthetic methods,
    so anything that hasn't defined serialVersionUID risks being broken.

    Mark Thornton
    Mark Thornton, Nov 19, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. umhlali
    Replies:
    0
    Views:
    2,038
    umhlali
    May 27, 2004
  2. Replies:
    8
    Views:
    2,233
    deadsea
    Jan 2, 2005
  3. Replies:
    3
    Views:
    1,022
  4. Dimitri Ognibene
    Replies:
    4
    Views:
    776
    Dimitri Ognibene
    Sep 2, 2006
  5. Ramunas Urbonas
    Replies:
    1
    Views:
    391
    Dino Chiesa [Microsoft]
    Jul 27, 2004
Loading...

Share This Page