JDK-6521742 : [BI] BreakIterator.isBoundary(int��offset) throws unspecified IllegalArgumentException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-02-06
  • Updated: 2017-05-16
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b22Fixed
Related Reports
Relates :  
Description
BreakIterator.isBoundary(int offset) throws IllegalArgumentException in case when
offset is out of bounds of the text.

Please find below the sample for the issue:
----------------------------------------------------------------
        String text = "hello world";
        int values[] = {-100, -1, text.length() + 1, 100};
        BreakIterator iter = BreakIterator.getWordInstance();
        iter.setText("hello world");

        for (int offset : values) {
            try {
                iter.isBoundary(offset);
                System.out.println("not thrown for offset: " + offset);
            } catch (IllegalArgumentException ex) {
            }
        }
----------------------------------------------------------------

Comments
EVALUATION It's difficult to fix this bug now. Because BreakIterator.isBoundary()'s spec doesn't tell that IAE can be thrown, IAE should not be thrown in this method in any invalid-offset cases. However, it's very difficult to modify RuleBasedBreakIterator.isBoundary() not to throw IAE due to backward compatibility. We can imagine that some people have troubles if this method stops throwing IAE. And, it's very difficult to modify BeakIterator.isBoundary()'s spec, too. BreakIterator is a public abstract class, and users can create a subclass of it. Spec change won't be welcomed.
07-02-2007