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

(coll spec) The 1.5 Iterator.next specification changes Iterator's contract

XMLWordPrintable

      Name: jl125535 Date: 07/30/2004


      FULL PRODUCT VERSION :
      J2SE 1.5.0

      A DESCRIPTION OF THE PROBLEM :
      The new specification for the Iterator.next method erroneously included an additional line that says:

      "Calling this method repeatedly until the hasNext() method returns false will return each element in the underlying collection exactly once. "

      This line was probably added due to the Bug ID # 4944089 (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4944089) where the person was confused about how his Circular Iterator should work. He's wrong by the way.

      The addition of this new line implies that Iterator's implementation is required to traverse ALL of the elements of the underlying collection (via a call to next). This isn't true and implementations such as predicate iterators would break Iterator's contract if that were so.

      The iterators for which the above line is true are the ones returned from the Collection.iterator() method. That line should be changed in context and moved there.




      REPRODUCIBILITY :
      This bug can be reproduced always.

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 290442)
      ======================================================================

            sseligmasunw Scott Seligman (Inactive)
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: