test/jdk/java/text/Collator/Bug5047314.java
author tschatzl
Wed, 24 Jul 2019 11:49:39 +0200
changeset 57508 28ab01c06755
parent 47216 71c04702a3d5
permissions -rw-r--r--
8228388: Add information about dirty/skipped card for Merge HCC in G1 log Summary: Collect and print informatio about the number of processed cards during the Merge HCC phase to improve log output. Reviewed-by: kbarrett, sangheki
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4839
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4839
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
4839
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
     4
 *
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
     8
 *
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    13
 * accompanied this code).
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    14
 *
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4839
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4839
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4839
diff changeset
    21
 * questions.
4839
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    22
 */
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    23
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    24
/*
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    25
 * @test
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    26
 * @bug 5047314
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    27
 * @summary verify that compare() and getCollationKey() don't go into an infinite loop for unfinished Thai/Lao text.
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    28
 * @run main/timeout=60 Bug5047314
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    29
 */
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    30
import java.text.Collator;
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    31
import java.util.Locale;
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    32
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    33
public class Bug5047314 {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    34
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    35
    private static Collator colLao = Collator.getInstance(new Locale("lo"));
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    36
    private static Collator colThai = Collator.getInstance(new Locale("th"));
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    37
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    38
    private static String[] textLao = {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    39
        "\u0ec0", "\u0ec1", "\u0ec2", "\u0ec3", "\u0ec4"
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    40
    };
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    41
    private static String[] textThai = {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    42
        "\u0e40", "\u0e41", "\u0e42", "\u0e43", "\u0e44"
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    43
    };
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    44
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    45
    public static void main(String[] args) {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    46
        testLao1();
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    47
        testLao2();
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    48
        testThai1();
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    49
        testThai2();
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    50
    }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    51
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    52
    private static void testLao1() {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    53
        System.out.print("Test(Lao 1) .... ");
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    54
        for (int i = 0; i < textLao.length; i++) {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    55
            colLao.compare(textLao[i], textLao[i]);
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    56
        }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    57
        System.out.println("Passed.");
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    58
    }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    59
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    60
    private static void testLao2() {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    61
        System.out.print("Test(Lao 2) .... ");
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    62
        for (int i = 0; i < textLao.length; i++) {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    63
            colLao.compare(textLao[i], textLao[i]);
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    64
        }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    65
        System.out.println("Passed.");
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    66
    }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    67
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    68
    private static void testThai1() {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    69
        System.out.print("Test(Thai 1) .... ");
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    70
        for (int i = 0; i < textThai.length; i++) {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    71
            colThai.compare(textThai[i], textThai[i]);
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    72
        }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    73
        System.out.println("Passed.");
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    74
    }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    75
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    76
    private static void testThai2() {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    77
        System.out.print("Test(Thai 2) .... ");
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    78
        for (int i = 0; i < textThai.length; i++) {
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    79
            colThai.getCollationKey(textThai[i]);
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    80
        }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    81
        System.out.println("Passed.");
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    82
    }
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    83
6b3edc448285 5047314: [Col] Collator.compare() runs indefinitely for a certain set of Thai strings
peytoia
parents:
diff changeset
    84
}