(coll) AbstractList$Itr is not serializable

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 1.4.2
    • Component/s: core-libs

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


      ADDITIONAL OS VERSION INFORMATION :
      Linux ******* 2.4.20-46.7.legacysmp #1 SMP Sat Mar 4 14:58:59 EST 2006 i686 unknown

      A DESCRIPTION OF THE PROBLEM :
      Attempt to serialize an object with an instance of java.util.AbstractList$Itr reachable from it results in a java.io.NotSerializableException

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(new ArrayList().iterator());

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      silently succeed

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.io.NotSerializableException: java.util.AbstractList$Itr

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.ByteArrayOutputStream;
      import java.io.IOException;
      import java.io.ObjectOutputStream;
      import java.util.ArrayList;

      public class Test
      {
          public static void main(String[] args) throws IOException
          {
              new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(new ArrayList().iterator());
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Store the list and an index instead of the iterator. This workaround doesn't work well with sequentially accessible lists, and breaks down completely with nonlist collections though.

            Assignee:
            Martin Buchholz
            Reporter:
            Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: