Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19197

Re: serializing

Newsgroups comp.lang.java.programmer
Date 2012-10-08 17:06 -0700
References <fe978849-c763-4bfb-a8b1-58ffd7203a24@googlegroups.com> <50732644$0$293$14726298@news.sunsite.dk> <k4vmt5$7v2$1@dont-email.me>
Message-ID <fa6242a2-6ee8-4d49-9f58-a390beb35986@googlegroups.com> (permalink)
Subject Re: serializing
From Lew <lewbloch@gmail.com>

Show all headers | View raw


markspace wrote:
> Arne Vajh�j wrote:
>> ObjectOutputStream and ObjectInputStream will get it right.
> 
> Thanks for pointing that out.  I would have guessed that serialization 
> would not get this right.

http://docs.oracle.com/javase/7/docs/platform/serialization/spec/serialTOC.html

Linked from the java.io API docs.

"The writeObject method (see Section 2.3, "The writeObject Method") serializes the specified object and 
traverses its references to other objects in the object graph recursively to create a complete serialized 
representation of the graph. Within a stream, the first reference to any object results in the object being 
serialized or externalized and the assignment of a handle for that object. Subsequent references to that 
object are encoded as the handle. Using object handles preserves sharing and circular references that 
occur naturally in object graphs. Subsequent references to an object use only the handle allowing a very
compact representation."

No need for guesswork.

> Does anyone know what XmlEncoder/Decoder do off hand?  I would think the 
> problem is even harder here, but maybe there's a trick they use to 
> prevent errors there too.

The API docs do.

http://docs.oracle.com/javase/7/docs/api/java/beans/XMLEncoder.html
“XML's standard "id" and "idref" attributes are used to make references to previous expressions - 
so as to deal with circularities in the object graph.”

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

serializing bob smith <bob@coolfone.comze.com> - 2012-10-08 12:08 -0700
  Re: serializing Arne Vajhøj <arne@vajhoej.dk> - 2012-10-08 15:15 -0400
    Re: serializing markspace <-@.> - 2012-10-08 16:16 -0700
      Re: serializing Lew <lewbloch@gmail.com> - 2012-10-08 17:06 -0700
        Re: serializing markspace <-@.> - 2012-10-08 19:29 -0700
      Re: serializing Roedy Green <see_website@mindprod.com.invalid> - 2012-10-09 17:27 -0700
        Re: serializing Arne Vajhøj <arne@vajhoej.dk> - 2012-10-09 21:01 -0400
      Re: serializing Arne Vajhøj <arne@vajhoej.dk> - 2012-10-09 21:00 -0400
  Re: serializing Lew <lewbloch@gmail.com> - 2012-10-08 14:58 -0700
    Re: serializing Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-10-09 01:59 +0200
      Re: serializing Lew <lewbloch@gmail.com> - 2012-10-08 17:07 -0700
  Re: serializing Roedy Green <see_website@mindprod.com.invalid> - 2012-10-09 02:09 -0700

csiph-web