author | mikael |
Mon, 29 Jul 2019 09:59:04 -0700 | |
changeset 57584 | 9d82a35b6ff7 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
35783
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
1 |
/* |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
4 |
* |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
8 |
* |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
13 |
* accompanied this code). |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
14 |
* |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
18 |
* |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
21 |
* questions. |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
22 |
*/ |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
23 |
|
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
24 |
/** |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
25 |
* @test |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
26 |
* @bug 8147531 |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
27 |
* @summary Check j.l.Character.getName and codePointOf |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
28 |
*/ |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
29 |
|
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
30 |
import java.util.Locale; |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
31 |
|
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
32 |
public class CharacterName { |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
33 |
|
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
34 |
public static void main(String[] args) { |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
35 |
for (int cp = 0; cp < Character.MAX_CODE_POINT; cp++) { |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
36 |
if (!Character.isValidCodePoint(cp)) { |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
37 |
try { |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
38 |
Character.getName(cp); |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
39 |
} catch (IllegalArgumentException x) { |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
40 |
continue; |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
41 |
} |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
42 |
throw new RuntimeException("Invalid failed: " + cp); |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
43 |
} else if (Character.getType(cp) == Character.UNASSIGNED) { |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
44 |
if (Character.getName(cp) != null) |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
45 |
throw new RuntimeException("Unsigned failed: " + cp); |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
46 |
} else { |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
47 |
String name = Character.getName(cp); |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
48 |
if (cp != Character.codePointOf(name) || |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
49 |
cp != Character.codePointOf(name.toLowerCase(Locale.ENGLISH))) |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
50 |
throw new RuntimeException("Roundtrip failed: " + cp); |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
51 |
} |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
52 |
} |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
53 |
} |
2690535d72cc
7071819: To support Extended Grapheme Clusters in Regex
sherman
parents:
diff
changeset
|
54 |
} |