United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6521742 : [BI] BreakIterator.isBoundary(int??offset) throws unspecified IllegalArgumentException

Details
Type:
Bug
Submit Date:
2007-02-06
Status:
Closed
Updated Date:
2012-03-22
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
core-libs
OS:
generic
Sub-Component:
java.text
CPU:
generic
Priority:
P5
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Relates:

Sub Tasks

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.
                                     
2007-02-07



Hardware and Software, Engineered to Work Together