Harmony
  1. Harmony
  2. HARMONY-62

[classlib][text] java.text.BreakIterator.getSentenceInstance().next() treats '\n' as the end of the sentence

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None

      Description

      Problem details:
      java.text.BreakIterator.getSentenceInstance().next() stops searching for the sentence end, if the new-line character is found in the text and returns the index of the last seen non white space character. Due to j2se 1.4.2 method next() should return the boundary following the current boundary.

      Code for reproducing Test.java:
      import java.text.BreakIterator;
      public class Test {
      public static void main(String [] args)

      { BreakIterator it = BreakIterator.getSentenceInstance(); it.setText("One sentence \n on two lines."); System.out.println(it.next()); }

      }

      Steps to Reproduce:
      1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt.
      2. Compile Test.java using BEA 1.4 javac
      > javac -d . Test.java
      3. Run java using compatible VM (J9)
      > java -showversion Test

      Output:
      java version 1.4.2 (subset)
      (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.
      14

      Output on BEA 1.4.2 to compare with:
      28

      Suggested junit test case:

      package org.apache.harmony.tests.java.text;

      import java.text.BreakIterator;
      import java.util.Locale;

      import junit.framework.TestCase;

      public class BreakIteratorTest extends TestCase {

      public void test_next()

      { // Regression test for HARMONY-30 BreakIterator bi = BreakIterator.getWordInstance(Locale.US); bi.setText("This is the test, WordInstance"); int n = bi.first(); n = bi.next(); assertEquals("Assert 0: next() returns incorrect value ", 4, n); // Regression test for the current issue bi = BreakIterator.getSentenceInstance(); bi.setText("One sentence \n on two lines."); n = bi.next(); assertEquals("Assert 1: next() returns incorrect value ", 28, n); }

      }

        Issue Links

          Activity

          Hide
          Alexey Petrenko added a comment -

          java.text.BreakIterator.getSentenceInstance() returns a wraper for com.ibm.icu.text.BreakIterator.getLineInstance() result.
          So it's probably ICU bug.

          Show
          Alexey Petrenko added a comment - java.text.BreakIterator.getSentenceInstance() returns a wraper for com.ibm.icu.text.BreakIterator.getLineInstance() result. So it's probably ICU bug.
          Hide
          Alexey Petrenko added a comment -

          Here is some bug in ICU database which is probably covers our issue
          http://bugs.icu-project.org/cgi-bin/icu-bugs/textbounds?id=4850

          Show
          Alexey Petrenko added a comment - Here is some bug in ICU database which is probably covers our issue http://bugs.icu-project.org/cgi-bin/icu-bugs/textbounds?id=4850
          Hide
          Vera Petrashkova added a comment -

          It looks like there is the same issues in behavior of BreakIterator.getSentenceInstance().next() method
          when the used text contains the combinations of the following symbols:
          ".", "!", "?"
          In these cases next() returns results which are differ from RI results.

          Test getSentenceInstance_check demonstrates this problem.
          Output is:
          -----------------
          ."What's the matter?.."
          F.I was pretty shaken up!..
          F."...I was pretty shaken up..." - he sad.
          F
          Time: 0.625
          There were 3 failures:
          1) test1(getSentenceInstance_check)junit.framework.AssertionFailedError: Incorrect result
          expected:<22> but was:<19>
          at getSentenceInstance_check.test1(getSentenceInstance_check.java:12)
          at java.lang.reflect.VMReflection.invokeMethod(Native Method)
          2) test2(getSentenceInstance_check)junit.framework.AssertionFailedError: Incorrect result
          expected:<25> but was:<23>
          at getSentenceInstance_check.test2(getSentenceInstance_check.java:20)
          at java.lang.reflect.VMReflection.invokeMethod(Native Method)
          3) test3(getSentenceInstance_check)junit.framework.AssertionFailedError: Incorrect result
          expected:<40> but was:<2>
          at getSentenceInstance_check.test3(getSentenceInstance_check.java:29)
          at java.lang.reflect.VMReflection.invokeMethod(Native Method)

          FAILURES!!!
          Tests run: 3, Failures: 3, Errors: 0

          This issue causes the failure of reliability test
          api.text.getSentenceInstance_check

          Show
          Vera Petrashkova added a comment - It looks like there is the same issues in behavior of BreakIterator.getSentenceInstance().next() method when the used text contains the combinations of the following symbols: ".", "!", "?" In these cases next() returns results which are differ from RI results. Test getSentenceInstance_check demonstrates this problem. Output is: ----------------- ."What's the matter?.." F.I was pretty shaken up!.. F."...I was pretty shaken up..." - he sad. F Time: 0.625 There were 3 failures: 1) test1(getSentenceInstance_check)junit.framework.AssertionFailedError: Incorrect result expected:<22> but was:<19> at getSentenceInstance_check.test1(getSentenceInstance_check.java:12) at java.lang.reflect.VMReflection.invokeMethod(Native Method) 2) test2(getSentenceInstance_check)junit.framework.AssertionFailedError: Incorrect result expected:<25> but was:<23> at getSentenceInstance_check.test2(getSentenceInstance_check.java:20) at java.lang.reflect.VMReflection.invokeMethod(Native Method) 3) test3(getSentenceInstance_check)junit.framework.AssertionFailedError: Incorrect result expected:<40> but was:<2> at getSentenceInstance_check.test3(getSentenceInstance_check.java:29) at java.lang.reflect.VMReflection.invokeMethod(Native Method) FAILURES!!! Tests run: 3, Failures: 3, Errors: 0 This issue causes the failure of reliability test api.text.getSentenceInstance_check
          Hide
          Alexei Fedotov added a comment -

          The bug http://bugs.icu-project.org/trac/ticket/4850 is marked as fixed in ICU database in 3.6 release, but our VM continues printing 14. What is the status of new ICU integration?

          Show
          Alexei Fedotov added a comment - The bug http://bugs.icu-project.org/trac/ticket/4850 is marked as fixed in ICU database in 3.6 release, but our VM continues printing 14. What is the status of new ICU integration?

            People

            • Assignee:
              Unassigned
              Reporter:
              tatyana doubtsova
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Development