author | sherman |
Mon, 16 Feb 2015 14:53:59 -0800 | |
changeset 28969 | f980bee32887 |
parent 25859 | 3317bb8137f4 |
child 34882 | ce2a8ec851c1 |
permissions | -rw-r--r-- |
22639
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
1 |
/* |
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. |
22639
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
3 |
* |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
5 |
* |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. Oracle designates this |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
9 |
* particular file as subject to the "Classpath" exception as provided |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
10 |
* by Oracle in the LICENSE file that accompanied this code. |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
11 |
* |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
12 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
14 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
15 |
* version 2 for more details (a copy is included in the LICENSE file that |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
16 |
* accompanied this code). |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
17 |
* |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License version |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
19 |
* 2 along with this work; if not, write to the Free Software Foundation, |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
20 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
21 |
* |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
22 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
23 |
* or visit www.oracle.com if you need additional information or have any |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
24 |
* questions. |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
25 |
* |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
26 |
*/ |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
27 |
|
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
28 |
// -- This file was mechanically generated: Do not edit! -- // |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
29 |
|
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
30 |
package sun.nio.cs; |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
31 |
|
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
32 |
import java.nio.charset.Charset; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
33 |
import java.nio.charset.spi.CharsetProvider; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
34 |
import java.util.Iterator; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
35 |
import java.util.Locale; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
36 |
import java.util.Map; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
37 |
import java.security.AccessController; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
38 |
import java.security.PrivilegedAction; |
22639
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
39 |
|
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
40 |
public class StandardCharsets extends CharsetProvider { |
22639
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
41 |
|
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
42 |
_INCLUDE_ALIASES_TABLES_ |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
43 |
_INCLUDE_ALIASES_MAP_ |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
44 |
_INCLUDE_CLASSES_MAP_ |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
45 |
_INCLUDE_CACHE_MAP_ |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
46 |
|
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
47 |
// Maps canonical names to class names |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
48 |
private Map<String,String> classMap; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
49 |
// Maps alias names to canonical names |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
50 |
private Map<String,String> aliasMap; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
51 |
// Maps canonical names to cached instances |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
52 |
private Map<String,Charset> cache; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
53 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
54 |
private String packagePrefix = "sun.nio.cs"; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
55 |
|
22639
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
56 |
public StandardCharsets() { |
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
57 |
this.aliasMap = new Aliases(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
58 |
this.classMap = new Classes(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
59 |
this.cache = new Cache(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
60 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
61 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
62 |
private String canonicalize(String csn) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
63 |
String acn = aliasMap.get(csn); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
64 |
return (acn != null) ? acn : csn; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
65 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
66 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
67 |
// Private ASCII-only version, optimized for interpretation during startup |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
68 |
// |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
69 |
private static String toLower(String s) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
70 |
int n = s.length(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
71 |
boolean allLower = true; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
72 |
for (int i = 0; i < n; i++) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
73 |
int c = s.charAt(i); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
74 |
if (((c - 'A') | ('Z' - c)) >= 0) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
75 |
allLower = false; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
76 |
break; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
77 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
78 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
79 |
if (allLower) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
80 |
return s; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
81 |
char[] ca = new char[n]; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
82 |
for (int i = 0; i < n; i++) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
83 |
int c = s.charAt(i); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
84 |
if (((c - 'A') | ('Z' - c)) >= 0) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
85 |
ca[i] = (char)(c + 0x20); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
86 |
else |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
87 |
ca[i] = (char)c; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
88 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
89 |
return new String(ca); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
90 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
91 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
92 |
private Charset lookup(String charsetName) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
93 |
init(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
94 |
String csn = canonicalize(toLower(charsetName)); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
95 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
96 |
// Check cache first |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
97 |
Charset cs = cache.get(csn); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
98 |
if (cs != null) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
99 |
return cs; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
100 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
101 |
// Do we even support this charset? |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
102 |
String cln = classMap.get(csn); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
103 |
if (cln == null) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
104 |
return null; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
105 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
106 |
if (cln.equals("US_ASCII")) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
107 |
cs = new US_ASCII(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
108 |
cache.put(csn, cs); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
109 |
return cs; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
110 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
111 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
112 |
// Instantiate the charset and cache it |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
113 |
try { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
114 |
Class<?> c = Class.forName(packagePrefix + "." + cln, |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
115 |
true, |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
116 |
this.getClass().getClassLoader()); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
117 |
cs = (Charset)c.newInstance(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
118 |
cache.put(csn, cs); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
119 |
return cs; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
120 |
} catch (ClassNotFoundException | |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
121 |
IllegalAccessException | |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
122 |
InstantiationException x) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
123 |
return null; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
124 |
} |
22639
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
125 |
} |
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
126 |
|
28969
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
127 |
public final Charset charsetForName(String charsetName) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
128 |
synchronized (this) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
129 |
return lookup(canonicalize(charsetName)); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
130 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
131 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
132 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
133 |
public final Iterator<Charset> charsets() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
134 |
synchronized (this) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
135 |
init(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
136 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
137 |
return new Iterator<Charset>() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
138 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
139 |
Iterator<String> i = classMap.keySet().iterator(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
140 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
141 |
public boolean hasNext() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
142 |
return i.hasNext(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
143 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
144 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
145 |
public Charset next() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
146 |
String csn = i.next(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
147 |
return lookup(csn); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
148 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
149 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
150 |
public void remove() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
151 |
throw new UnsupportedOperationException(); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
152 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
153 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
154 |
}; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
155 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
156 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
157 |
private boolean initialized = false; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
158 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
159 |
/* provider the sun.nio.cs.map property fir sjis/ms932 mapping hack |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
160 |
*/ |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
161 |
private void init() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
162 |
if (initialized) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
163 |
return; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
164 |
if (!sun.misc.VM.isBooted()) |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
165 |
return; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
166 |
initialized = true; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
167 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
168 |
String map = getProperty("sun.nio.cs.map"); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
169 |
if (map != null) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
170 |
String[] maps = map.split(","); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
171 |
for (int i = 0; i < maps.length; i++) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
172 |
if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
173 |
// if we dont have both sjis and ms932, do nothing |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
174 |
if (classMap.get("shift_jis") == null || |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
175 |
classMap.get("windows-31j") == null) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
176 |
break; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
177 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
178 |
aliases_MS932 = new String[] { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
179 |
"MS932", // JDK historical |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
180 |
"windows-932", |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
181 |
"csWindows31J", |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
182 |
"shift-jis", |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
183 |
"ms_kanji", |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
184 |
"x-sjis", |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
185 |
"csShiftJIS", |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
186 |
// This alias takes precedence over the actual |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
187 |
// Shift_JIS charset itself since aliases are always |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
188 |
// resolved first, before looking up canonical names. |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
189 |
"shift_jis" |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
190 |
}; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
191 |
aliases_SJIS = new String[] { "sjis" }; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
192 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
193 |
for (String alias : aliases_MS932) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
194 |
aliasMap.put(toLower(alias), "windows-31j"); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
195 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
196 |
cache.put("shift_jis", null); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
197 |
break; |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
198 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
199 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
200 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
201 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
202 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
203 |
private static String getProperty(String key) { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
204 |
// this method may be called during initialization of |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
205 |
// system class loader and thus not using lambda |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
206 |
return AccessController.doPrivileged( |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
207 |
new PrivilegedAction<String>() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
208 |
@Override |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
209 |
public String run() { |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
210 |
return System.getProperty(key); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
211 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
212 |
}); |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
213 |
} |
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
214 |
|
f980bee32887
8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
25859
diff
changeset
|
215 |
|
22639
37f4508257fe
8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff
changeset
|
216 |
} |