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

Undocumented exceptions in java.text.StringCharacterIterator

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • core-libs
    • None
    • behavioral
    • minimal
    • Reflect the actual behavior in the specification.
    • Java API
    • SE

      Summary

      Undocumented exceptions in the public class java.text.StringCharacterIterator.

      Problem

      Conformance issue, the specification of java.text.StringCharacterIterator should properly document the exceptions in the implementation.

      Solution

      Use @throws tag to specify the missing exceptions for 5 methods/constructors.

      Specification

      --- a/src/java.base/share/classes/java/text/StringCharacterIterator.java
      +++ b/src/java.base/share/classes/java/text/StringCharacterIterator.java
      
            * Constructs an iterator with an initial index of 0.
            *
            * @param text the {@code String} to be iterated over
      +     * @throws NullPointerException if {@code text} is {@code null}
            */
           public StringCharacterIterator(String text)
           {
      
            *
            * @param  text   The String to be iterated over
            * @param  pos    Initial iterator position
      +     * @throws NullPointerException if {@code text} is {@code null}
      +     * @throws IllegalArgumentException if {@code pos} is not within the bounds of
      +     * range (inclusive) from {@code 0} to the length of {@code text}
            */
           public StringCharacterIterator(String text, int pos)
           {
      
           /**
            * @param  begin  Index of the first character
            * @param  end    Index of the character following the last character
            * @param  pos    Initial iterator position
      +     * @throws NullPointerException if {@code text} is {@code null}
      +     * @throws IllegalArgumentException if {@code begin} and {@code end} are not
      +     * within the bounds of range (inclusive) from {@code 0} to the length of {@code text},
      +     * {@code begin} is greater than {@code end}, or {@code pos} is not within
      +     * the bounds of range (inclusive) from {@code begin} to {@code end}
            */
           public StringCharacterIterator(String text, int begin, int end, int pos) {
      
            *
            * @param  text   The String to be iterated over
      +     * @throws NullPointerException if {@code text} is {@code null}
            * @since 1.2
            */
           public void setText(String text) {
      
           /**
            * Implements CharacterIterator.setIndex() for String.
      +     *
      +     * @throws IllegalArgumentException if {@code p} is not within the bounds
      +     * (inclusive) of {@link #getBeginIndex()} to {@link #getEndIndex()}
            * @see CharacterIterator#setIndex
            */
           public char setIndex(int p)

            jlu Justin Lu
            jlu Justin Lu
            Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: