# HG changeset patch # User mchung # Date 1485370381 28800 # Node ID 8c539ce463449c9de76649040e269361c42060cb # Parent ef028cd46c9d820c5dd70a597bde2dc7ce65b551 8172808: Handle sun.security.util.Resources bundle in ResourcesMgr in the same way as AuthResources Reviewed-by: mullan diff -r ef028cd46c9d -r 8c539ce46344 jdk/src/java.base/share/classes/sun/security/util/LocalizedMessage.java --- a/jdk/src/java.base/share/classes/sun/security/util/LocalizedMessage.java Wed Jan 25 15:53:17 2017 +0100 +++ b/jdk/src/java.base/share/classes/sun/security/util/LocalizedMessage.java Wed Jan 25 10:53:01 2017 -0800 @@ -4,7 +4,9 @@ * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or diff -r ef028cd46c9d -r 8c539ce46344 jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java --- a/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java Wed Jan 25 15:53:17 2017 +0100 +++ b/jdk/src/java.base/share/classes/sun/security/util/ResourcesMgr.java Wed Jan 25 10:53:01 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,37 +34,24 @@ */ public class ResourcesMgr { // intended for java.security, javax.security and sun.security resources - private final static String RESOURCES = "sun.security.util.Resources"; - private final static String AUTH_RESOURCES = "sun.security.util.AuthResources"; - private final static Map bundles = new ConcurrentHashMap<>(); public static String getString(String s) { - ResourceBundle bundle = bundles.get(RESOURCES); - if (bundle == null) { - - // only load if/when needed - bundle = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public java.util.ResourceBundle run() { - return (java.util.ResourceBundle.getBundle - ("sun.security.util.Resources")); - } - }); - } - - return bundle.getString(s); + return getBundle("sun.security.util.Resources").getString(s); } public static String getAuthResourceString(String s) { - if (VM.initLevel() == 3) { - // cannot trigger loading of any resource bundle as - // it depends on the system class loader fully initialized. - throw new InternalError("system class loader is being initialized"); + return getBundle("sun.security.util.AuthResources").getString(s); + } + + private static ResourceBundle getBundle(String bundleName) { + if (!VM.isBooted()) { + // don't expect this be called before the system is fully initialized. + // This triggers loading of any resource bundle that should be + // be done during initialization of system class loader. + throw new InternalError("Expected to use ResourceBundle only after booted"); } - - return bundles.computeIfAbsent(AUTH_RESOURCES, ResourceBundle::getBundle) - .getString(s); + return bundles.computeIfAbsent(bundleName, ResourceBundle::getBundle); } } diff -r ef028cd46c9d -r 8c539ce46344 jdk/test/sun/security/util/Resources/customSysClassLoader/CustomClassLoader.java --- a/jdk/test/sun/security/util/Resources/customSysClassLoader/CustomClassLoader.java Wed Jan 25 15:53:17 2017 +0100 +++ b/jdk/test/sun/security/util/Resources/customSysClassLoader/CustomClassLoader.java Wed Jan 25 10:53:01 2017 -0800 @@ -5,9 +5,7 @@ * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or