jdk/src/java.base/share/classes/sun/nio/cs/StandardCharsets.java.template
author redestad
Tue, 03 May 2016 15:50:54 +0200
changeset 37781 71ed5645f17c
parent 37593 824750ada3d6
child 37782 ad8fe7507ecc
permissions -rw-r--r--
8155775: Re-examine naming of privileged methods to access System properties Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
37593
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 34882
diff changeset
    37
import sun.security.action.GetPropertyAction;
22639
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
    38
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    39
public class StandardCharsets extends CharsetProvider {
22639
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
    40
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
    41
    _INCLUDE_ALIASES_TABLES_
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
    42
    _INCLUDE_ALIASES_MAP_
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
    43
    _INCLUDE_CLASSES_MAP_
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
    44
    _INCLUDE_CACHE_MAP_
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
    45
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    46
    // Maps canonical names to class names
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    47
    private Map<String,String> classMap;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    48
    // Maps alias names to canonical names
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    49
    private Map<String,String> aliasMap;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    50
    // Maps canonical names to cached instances
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    51
    private Map<String,Charset> cache;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    52
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    53
    private String packagePrefix = "sun.nio.cs";
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    54
22639
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
    55
    public StandardCharsets() {
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    56
        this.aliasMap = new Aliases();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    57
        this.classMap = new Classes();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    58
        this.cache = new Cache();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    59
    }
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
    private String canonicalize(String csn) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    62
        String acn = aliasMap.get(csn);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    63
        return (acn != null) ? acn : csn;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    64
    }
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
    // Private ASCII-only version, optimized for interpretation during startup
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    67
    //
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    68
    private static String toLower(String s) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    69
        int n = s.length();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    70
        boolean allLower = true;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    71
        for (int i = 0; i < n; i++) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    72
            int c = s.charAt(i);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    73
            if (((c - 'A') | ('Z' - c)) >= 0) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    74
                allLower = false;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    75
                break;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    76
            }
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
        if (allLower)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    79
            return s;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    80
        char[] ca = new char[n];
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    81
        for (int i = 0; i < n; i++) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    82
            int c = s.charAt(i);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    83
            if (((c - 'A') | ('Z' - c)) >= 0)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    84
                ca[i] = (char)(c + 0x20);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    85
            else
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    86
                ca[i] = (char)c;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    87
        }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    88
        return new String(ca);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    89
    }
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
    private Charset lookup(String charsetName) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    92
        init();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    93
        String csn = canonicalize(toLower(charsetName));
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    94
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    95
        // Check cache first
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    96
        Charset cs = cache.get(csn);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    97
        if (cs != null)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    98
            return cs;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
    99
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   100
        // Do we even support this charset?
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   101
        String cln = classMap.get(csn);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   102
        if (cln == null)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   103
            return null;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   104
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   105
        if (cln.equals("US_ASCII")) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   106
            cs = new US_ASCII();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   107
            cache.put(csn, cs);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   108
            return cs;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   109
        }
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
        // Instantiate the charset and cache it
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   112
        try {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   113
            Class<?> c = Class.forName(packagePrefix + "." + cln,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   114
                                    true,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   115
                                    this.getClass().getClassLoader());
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   116
            cs = (Charset)c.newInstance();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   117
            cache.put(csn, cs);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   118
            return cs;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   119
        } catch (ClassNotFoundException |
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   120
                 IllegalAccessException |
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   121
                 InstantiationException x) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   122
            return null;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   123
        }
22639
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
   124
    }
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
   125
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   126
    public final Charset charsetForName(String charsetName) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   127
        synchronized (this) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   128
            return lookup(canonicalize(charsetName));
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   129
        }
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
    public final Iterator<Charset> charsets() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   133
        synchronized (this) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   134
            init();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   135
        }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   136
        return new Iterator<Charset>() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   137
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   138
                Iterator<String> i = classMap.keySet().iterator();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   139
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   140
                public boolean hasNext() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   141
                    return i.hasNext();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   142
                }
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
                public Charset next() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   145
                    String csn = i.next();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   146
                    return lookup(csn);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   147
                }
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
                public void remove() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   150
                    throw new UnsupportedOperationException();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   151
                }
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
    private boolean initialized = false;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   157
34882
ce2a8ec851c1 8145544: Move sun.misc.VM to jdk.internal.misc
chegar
parents: 28969
diff changeset
   158
    /*   provider the sun.nio.cs.map property fir sjis/ms932 mapping hack
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   159
     */
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   160
    private void init() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   161
        if (initialized)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   162
            return;
34882
ce2a8ec851c1 8145544: Move sun.misc.VM to jdk.internal.misc
chegar
parents: 28969
diff changeset
   163
        if (!jdk.internal.misc.VM.isBooted())
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   164
            return;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   165
        initialized = true;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   166
37781
71ed5645f17c 8155775: Re-examine naming of privileged methods to access System properties
redestad
parents: 37593
diff changeset
   167
        String map = GetPropertyAction.privilegedGetProperty("sun.nio.cs.map");
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   168
        if (map != null) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   169
            String[] maps = map.split(",");
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   170
            for (int i = 0; i < maps.length; i++) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   171
                if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   172
                    // 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
   173
                    if (classMap.get("shift_jis") == null ||
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   174
                        classMap.get("windows-31j") == null) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   175
                        break;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   176
                    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   177
                    aliases_MS932 = new String[] {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   178
                        "MS932",        // JDK historical
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   179
                        "windows-932",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   180
                        "csWindows31J",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   181
                        "shift-jis",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   182
                        "ms_kanji",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   183
                        "x-sjis",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   184
                        "csShiftJIS",
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   185
                        // This alias takes precedence over the actual
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   186
                        // Shift_JIS charset itself since aliases are always
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   187
                        // resolved first, before looking up canonical names.
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   188
                        "shift_jis"
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   189
                    };
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   190
                    aliases_SJIS = new String[] { "sjis" };
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   191
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   192
                    for (String alias : aliases_MS932) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   193
                        aliasMap.put(toLower(alias), "windows-31j");
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   194
                    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   195
                    cache.put("shift_jis", null);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   196
                    break;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 25859
diff changeset
   197
                }
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
22639
37f4508257fe 8033236: Update GensrcCharsetMapping.gmk to build-infra standards
ihse
parents:
diff changeset
   202
}