JDK-4153072 : java.text.BreakIterator.isBoundary(int offset) fails when beginIndex > 0
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5
  • CPU: sparc
  • Submitted: 1998-06-29
  • Updated: 1999-01-14
  • Resolved: 1998-07-29
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.
Other
1.2.0 1.2fcsFixed
Related Reports
Relates :  
Description

Name: dfC67450			Date: 06/29/98



The methods java.text.BreakIterator.isBoundary(int offset) does not throw  
IllegalArgumentException in case of offset == 0 when begin index of text for 
scanning is greater than 0. But it does it if offset == 1.

Here is the test demonstrating the bug:

--------- Test.java ----------
import java.text.*;

import java.text.*;

public class Test {
    public static void main (String args[]){
        boolean passed = true;
        BreakIterator iter = BreakIterator.getWordInstance();
        String str = "...Hello, World!...";
        int begin = 3;
        int end = str.length() - 3;
        iter.setText(new StringCharacterIterator(str, begin, end, begin));
        System.out.println("string for canning: \"" + str + "\"");
        System.out.println("begin: " + begin);
        System.out.println("end:   " + end);
        System.out.println();
        for (int index = -1; index <= begin + 1; index ++) {
          try {
              boolean returned = iter.isBoundary(index); // call method under test
              System.out.print("  isBoundary(" + index + "): " + returned);
              if (index < begin) {
                passed = false;
                System.out.print("   (should throw IllegalArgumentException)");
              }
          } catch (IllegalArgumentException e) { 
              System.out.print("  isBoundary(" + index + "):  IllegalArgumentException");
              if (index == begin) {
                passed = false;
                System.out.print("   (should return true)");
              }
          }
          System.out.println();
        }
        System.out.println();
        if (passed) { 
          System.out.println("Test passed");
        } else {
          System.out.println("Test failed");
        }
    }
} 
---------Output from the test---------------------
string for canning: "...Hello, World!..."
begin: 3
end:   16

  isBoundary(-1):  IllegalArgumentException
  isBoundary(0): true   (should throw IllegalArgumentException)
  isBoundary(1):  IllegalArgumentException
  isBoundary(2):  IllegalArgumentException
  isBoundary(3):  IllegalArgumentException   (should return true)
  isBoundary(4): false

Test failed
--------------------------------------------------

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2fcs INTEGRATED IN: 1.2fcs VERIFIED IN: 1.2fcs
14-06-2004

EVALUATION isBoundary() will be fixed. mark.son-bell@eng 1998-07-29
29-07-1998