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)
- csr of
-
JDK-8315410 Undocumented exceptions in java.text.StringCharacterIterator
-
- Resolved
-