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

LTP: XMLEncoder does not write java.util.Set implementations correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs
    • x86
    • windows_2000



      Name: gm110360 Date: 02/20/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Win2k SP2

      A DESCRIPTION OF THE PROBLEM :
      XMLEncoder always encodes HashSets and TreeSets as empty
      even if they are not empty.

      ArrayLists and Vectors are encoded correctly.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. create new HashSet
      2. add some elements
      3. let the XMLEncoder encode

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I expectected:
      Sets as well as Lists should be encoded including their
      contents.

      Reality:
      XMLEncoder refuses to write Set contents, though it does
      write List contents

      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.*;
      import java.beans.*;

      public class SetBug {

        public static void main(String[] args) throws Exception {

          List aList = new ArrayList();
          aList.add("foo");

          Set aSet = new HashSet();
          aSet.add("bar");

          XMLEncoder anEncoder = new XMLEncoder(System.out);
          anEncoder.writeObject(aSet);
          anEncoder.writeObject(aList);
          anEncoder.close();
        }
      }

      ---------- END SOURCE ----------
      (Review ID: 139836)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: