src/java.base/share/classes/sun/security/util/LocalizedMessage.java
author redestad
Wed, 22 May 2019 13:19:04 +0200
changeset 54980 e2c952c7ff20
parent 48757 8cc67294ec56
permissions -rw-r--r--
8224589: Improve startup behavior of SecurityProperties Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
     1
/*
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
     4
 *
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
43305
8c539ce46344 8172808: Handle sun.security.util.Resources bundle in ResourcesMgr in the same way as AuthResources
mchung
parents: 43297
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
8c539ce46344 8172808: Handle sun.security.util.Resources bundle in ResourcesMgr in the same way as AuthResources
mchung
parents: 43297
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
8c539ce46344 8172808: Handle sun.security.util.Resources bundle in ResourcesMgr in the same way as AuthResources
mchung
parents: 43297
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    10
 *
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    15
 * accompanied this code).
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    16
 *
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    20
 *
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    23
 * questions.
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    24
 */
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    25
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    26
package sun.security.util;
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    27
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    28
/**
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    29
 * This class produces formatted and localized messages describing security
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    30
 * issues. Some messages may be required when the VM is not fully booted. In
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    31
 * this case, localization resources and classes used for message formatting
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    32
 * may not be available. When the VM is not booted, the message will not be
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    33
 * localized, and it will be formatted using simplified message formatting
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    34
 * code that is contained in this class.
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    35
 */
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    36
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    37
/*
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    38
 * Some of this code is executed before the VM is fully booted. Some import
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    39
 * statements have been omitted to help prevent accidental use of classes that
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    40
 * may not be available during boot.
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    41
 */
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    42
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    43
public class LocalizedMessage {
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    44
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    45
    private static final Resources RESOURCES = new Resources();
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    46
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    47
    private final String key;
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    48
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    49
    /**
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    50
     * A LocalizedMessage can be instantiated with a key and formatted with
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    51
     * arguments later in the style of MessageFormat. This organization
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    52
     * allows the actual formatting (and associated permission checks) to be
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    53
     * avoided unless the resulting string is needed.
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    54
     * @param key
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    55
     */
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    56
    public LocalizedMessage(String key) {
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    57
        this.key = key;
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    58
    }
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    59
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    60
    /**
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    61
     * Return a localized string corresponding to the key stored in this
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    62
     * object, formatted with the provided arguments. This method should only
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    63
     * be called when the VM is booted and all resources needed to obtain
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    64
     * and format the localized message are loaded (or can be loaded).
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    65
     *
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    66
     * @param arguments The arguments that should be placed in the message
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    67
     * @return A formatted message string
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    68
     */
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    69
    public String formatLocalized(Object... arguments) {
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    70
        return getLocalized(key, arguments);
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    71
    }
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    72
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    73
    /**
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    74
     * Return a non-localized string corresponding to the key stored in this
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    75
     * object, formatted with the provided arguments. All strings are obtained
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    76
     * from sun.security.util.Resources, and the formatting only supports
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    77
     * simple positional argument replacement (e.g. {1}).
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    78
     *
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    79
     * @param arguments The arguments that should be placed in the message
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    80
     * @return A formatted message string
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    81
     */
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    82
    public String formatNonlocalized(Object... arguments) {
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    83
        return getNonlocalized(key, arguments);
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    84
    }
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    85
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    86
    /**
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    87
     * Return a non-localized string corresponding to the provided key, and
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    88
     * formatted with the provided arguments. All strings are obtained from
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    89
     * sun.security.util.Resources, and the formatting only supports
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    90
     * simple positional argument replacement (e.g. {1}).
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    91
     *
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    92
     * @param key The key of the desired string in Resources
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    93
     * @param arguments The arguments that should be placed in the message
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    94
     * @return A formatted message string
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    95
     */
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    96
    public static String getNonlocalized(String key,
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    97
                                                Object... arguments) {
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
    98
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
    99
        String value = RESOURCES.getString(key);
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   100
        if (arguments == null || arguments.length == 0) {
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   101
            return value;
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   102
        }
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   103
        // Classes like StringTokenizer may not be loaded, so parsing
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   104
        //   is performed with String methods
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   105
        StringBuilder sb = new StringBuilder();
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   106
        int nextBraceIndex;
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   107
        while ((nextBraceIndex = value.indexOf('{')) >= 0) {
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   108
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   109
            String firstPart = value.substring(0, nextBraceIndex);
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   110
            sb.append(firstPart);
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   111
            value = value.substring(nextBraceIndex + 1);
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   112
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   113
            // look for closing brace and argument index
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   114
            nextBraceIndex = value.indexOf('}');
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   115
            if (nextBraceIndex < 0) {
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   116
                // no closing brace
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   117
                // MessageFormat would throw IllegalArgumentException, but
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   118
                //   that exception class may not be loaded yet
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   119
                throw new RuntimeException("Unmatched braces");
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   120
            }
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   121
            String indexStr = value.substring(0, nextBraceIndex);
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   122
            try {
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   123
                int index = Integer.parseInt(indexStr);
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   124
                sb.append(arguments[index]);
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   125
            } catch (NumberFormatException e) {
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   126
                // argument index is not an integer
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   127
                throw new RuntimeException("not an integer: " + indexStr);
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   128
            }
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   129
            value = value.substring(nextBraceIndex + 1);
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   130
        }
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   131
        sb.append(value);
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   132
        return sb.toString();
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   133
    }
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   134
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   135
    /**
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   136
     * Return a localized string corresponding to the provided key, and
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   137
     * formatted with the provided arguments. This method should only be
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   138
     * called when the VM is booted and all resources needed to obtain
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   139
     * and format the localized message are loaded (or can be loaded).
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   140
     *
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   141
     * @param key The key of the desired string in the security resource bundle
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   142
     * @param arguments The arguments that should be placed in the message
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   143
     * @return A formatted message string
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   144
     */
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   145
    public static String getLocalized(String key, Object... arguments) {
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   146
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   147
        String value = ResourcesMgr.getString(key);
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   148
        if (arguments == null) {
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   149
            return value;
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   150
        }
48757
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   151
        java.text.MessageFormat form = new java.text.MessageFormat(value);
8cc67294ec56 8194251: Deadlock between UsageTracker and System.getProperty() when using a malformed security policy
apetcher
parents: 47216
diff changeset
   152
        return form.format(arguments);
43297
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   153
    }
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   154
05ad35b943d0 8168075: Custom system class loader + security manager + malformed policy file = recursive initialization
apetcher
parents:
diff changeset
   155
}