diff --git a/src/java.base/share/classes/sun/text/resources/BreakIteratorRules.java b/src/java.base/share/classes/sun/text/resources/BreakIteratorRules.java index 4283cd381c8..92bbe58f261 100644 --- a/src/java.base/share/classes/sun/text/resources/BreakIteratorRules.java +++ b/src/java.base/share/classes/sun/text/resources/BreakIteratorRules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -310,7 +310,7 @@ public class BreakIteratorRules extends ListResourceBundle { // punctuation" and quotation marks + "=[:Ps::Pi:\\\"\\\'];" - // punctuation with may occur at the end of a sentence: "ending punctuation" + // punctuation which may occur at the end of a sentence: "ending punctuation" // and quotation marks + "=[:Pe::Pf:\\\"\\\'];" @@ -323,9 +323,12 @@ public class BreakIteratorRules extends ListResourceBundle { // periods, which MAY signal the end of a sentence + "=[\\.\uff0e];" + // comma, which may not occur at the start of a sentence + + "=[\\,];" + // characters that may occur at the beginning of a sentence: basically anything // not mentioned above (letters and digits are specifically excluded) - + "=[^[:L:\u2029]];" + + "=[^[:L:\u2029]];" // Hindi phrase separator + "=[\u0964\u0965];" diff --git a/test/jdk/java/text/BreakIterator/BreakIteratorTest.java b/test/jdk/java/text/BreakIterator/BreakIteratorTest.java index 3c2498de48e..74265a11aee 100644 --- a/test/jdk/java/text/BreakIterator/BreakIteratorTest.java +++ b/test/jdk/java/text/BreakIterator/BreakIteratorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @bug 4035266 4052418 4068133 4068137 4068139 4086052 4095322 4097779 * 4097920 4098467 4111338 4113835 4117554 4143071 4146175 4152117 - * 4152416 4153072 4158381 4214367 4217703 4638433 + * 4152416 4153072 4158381 4214367 4217703 4638433 8264765 * @library /java/text/testlib * @run main/timeout=2000 BreakIteratorTest * @summary test BreakIterator @@ -746,6 +746,17 @@ public class BreakIteratorTest extends IntlTest generalIteratorTest(sentenceBreak, sentenceSelectionData); } + public void TestBug8264765() { + Vector sentenceSelectionData = new Vector(); + + // Comma should not be regarded as the start of a sentence, + // otherwise the backwards rule would break the following sentence. + sentenceSelectionData.addElement( + "Due to a problem (e.g., software bug), the server is down. "); + + generalIteratorTest(sentenceBreak, sentenceSelectionData); + } + public void TestLineBreak() { Vector lineSelectionData = new Vector();