Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4216178

Wanted: Debugging trace info when serialization fails

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 1.2.0, 1.3.1
    • core-libs



      Name: dbT83986 Date: 03/01/99


      Currently, debugging a problem in serialization code is difficult.
      The stack trace information that one gets is often just a long
      sequence of recursive writeObject()/readObject() calls. This tells
      one very little about where in the graph of objects that the
      serialization actually failed.

      What I'd like to see is a second trace that shows what objects
      were being serialized at the time. It should list the object
      (using toString()) and which field it was stored in. For example...

      java.io.NotSerializableException: Mustard
         field "toppings": Mustard["Grey Pupon"]
         field "lunch": Sandwich["Smoked Meat"]
         field "container": PinicBasket[Sandwich,Pop,PotatoChips]
         ...
         field "star": Star[Yellow,K7,"The Sun"]
         field "galaxy": SpiralArmedGalaxy["Milky Way"]
         root: Universe@12345678

      The above trace would very quickly show that either the class
      "Mustard" needs to be made serializable (which admittedly could
      be determined from the exception message) or that the "toppings"
      field in the "Sandwich" class needs to be made transient. This
      last insight would take a lot of luck if one had to manually
      trace all the references starting from the root Universe.

      I suggest that you make the necessary changes in the ObjectStreamException
      class. That way any exception specific to serialization will
      carry the "serialization trace". I'm not sure what format would
      make the most sense (the listing above is only an example). Also,
      I anticipate that you'll need to give special consideration to
      representing elements in an array.
      (Review ID: 53980)
      ======================================================================

            aozerov Andrey Ozerov
            dblairsunw Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: