author | jbachorik |
Tue, 21 Jan 2014 13:04:55 +0100 | |
changeset 22353 | d09e3ff5fd63 |
parent 14018 | 3c3bf69fbec7 |
permissions | -rw-r--r-- |
14018
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
1 |
/* |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
4 |
* |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
8 |
* |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
13 |
* accompanied this code). |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
14 |
* |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
18 |
* |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
21 |
* questions. |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
22 |
*/ |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
23 |
/* |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
24 |
* @test |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
25 |
* @bug 7104012 |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
26 |
* @summary Confirm that AIOBE is not thrown. |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
27 |
*/ |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
28 |
|
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
29 |
import java.text.*; |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
30 |
import java.util.*; |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
31 |
|
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
32 |
public class Bug7104012 { |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
33 |
|
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
34 |
public static void main(String[] args) { |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
35 |
boolean err = false; |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
36 |
|
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
37 |
List<String> data = new ArrayList<>(); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
38 |
data.add("\udb40"); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
39 |
data.add(" \udb40"); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
40 |
data.add("\udc53"); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
41 |
data.add(" \udc53"); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
42 |
data.add(" \udb40\udc53"); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
43 |
data.add("\udb40\udc53"); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
44 |
data.add("ABC \udb40\udc53 123"); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
45 |
data.add("\udb40\udc53 ABC \udb40\udc53"); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
46 |
|
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
47 |
for (Locale locale : Locale.getAvailableLocales()) { |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
48 |
List<BreakIterator> breakIterators = new ArrayList<>(); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
49 |
breakIterators.add(BreakIterator.getCharacterInstance(locale)); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
50 |
breakIterators.add(BreakIterator.getLineInstance(locale)); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
51 |
breakIterators.add(BreakIterator.getSentenceInstance(locale)); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
52 |
breakIterators.add(BreakIterator.getWordInstance(locale)); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
53 |
|
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
54 |
for (BreakIterator bi : breakIterators) { |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
55 |
for (String str : data) { |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
56 |
try { |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
57 |
bi.setText(str); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
58 |
bi.first(); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
59 |
while (bi.next() != BreakIterator.DONE) { } |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
60 |
bi.last(); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
61 |
while (bi.previous() != BreakIterator.DONE) { } |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
62 |
} |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
63 |
catch (ArrayIndexOutOfBoundsException ex) { |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
64 |
System.out.println(" " + data.indexOf(str) |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
65 |
+ ": BreakIterator(" + locale |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
66 |
+ ") threw AIOBE."); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
67 |
err = true; |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
68 |
} |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
69 |
} |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
70 |
} |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
71 |
} |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
72 |
|
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
73 |
if (err) { |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
74 |
throw new RuntimeException("Unexpected exeption."); |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
75 |
} |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
76 |
} |
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
77 |
|
3c3bf69fbec7
7104012: AIOOBE from RuleBasedBreakIterator.lookupState for some suppl. chars
peytoia
parents:
diff
changeset
|
78 |
} |