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

clarify semantics of Iterable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs

      Description

      The prevailing assumption about the Iterable interface is that such instances be independent of each other, that they not interfere with each other or with the underlying state of the implementing object, and that it be possible to create an arbitrary number of Iterators using successive calls to the iterator() method.

      However, the specification of Iterable is silent about all of these issues. While the semantics cannot be altered compatibly, a recommendation with the above could be added as an API note.

      The java.nio.file.DirectoryStream interface is a notable outlier here, as it implements Iterable but only one Iterator can be obtained from it. Since it's the outlier, it has a large warning to this effect.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                smarks Stuart Marks
                Reporter:
                smarks Stuart Marks
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: