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

Java API doc for XMLStreamReader.next() needs to be clarified for the exception thrown when hasNext() method returns false

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • Verification:
      Not verified

      Description

      A DESCRIPTION OF THE PROBLEM :
      In the Javadoc for XMLStreamReader.next() there are two references to a hasNext() method when it returns false.

      (a) "This method will throw an IllegalStateException if it is called after hasNext() returns false"

      (b) "Throws: NoSuchElementException - if this is called when hasNext() returns false

      The effect is that it is unclear what should happen when there are no more events to return. The state table in the class-level Javadoc states (i) that next() is not a valid method to call in END_DOCUMENT state, and (ii) that in such circumstances, IllegalStateException should be thrown. However, the "throws" documentation for next() suggests that the method can throw NoSuchElementException.

      I have not attempted to check the behaviour of existing implementations of the interface, since there are multiple implementations I'm not sure this would be useful.


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                joehw Joe Wang
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: