--- old/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java 2020-05-20 09:20:49.000000000 -0700 +++ new/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java 2020-05-20 09:20:49.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, 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 @@ -50,6 +50,8 @@ import sun.text.spi.JavaTimeDateTimePatternProvider; import sun.util.spi.CalendarProvider; +import static java.lang.System.*; + /** * The LocaleProviderAdapter abstract class. * @@ -60,7 +62,7 @@ /** * Adapter type. */ - public static enum Type { + public enum Type { JRE("sun.util.locale.provider.JRELocaleProviderAdapter", "sun.util.resources", "sun.text.resources"), CLDR("sun.util.cldr.CLDRLocaleProviderAdapter", "sun.util.resources.cldr", "sun.text.resources.cldr"), SPI("sun.util.locale.provider.SPILocaleProviderAdapter"), @@ -71,11 +73,11 @@ private final String UTIL_RESOURCES_PACKAGE; private final String TEXT_RESOURCES_PACKAGE; - private Type(String className) { + Type(String className) { this(className, null, null); } - private Type(String className, String util, String text) { + Type(String className, String util, String text) { CLASSNAME = className; UTIL_RESOURCES_PACKAGE = util; TEXT_RESOURCES_PACKAGE = text; @@ -113,12 +115,13 @@ /** * Adapter lookup cache. */ - private static ConcurrentMap, ConcurrentMap> + private static final ConcurrentMap, ConcurrentMap> adapterCache = new ConcurrentHashMap<>(); static { String order = GetPropertyAction.privilegedGetProperty("java.locale.providers"); - List typeList = new ArrayList<>(); + ArrayList typeList = new ArrayList<>(); + String invalidTypeMessage = null; // Check user specified adapter preference if (order != null && !order.isEmpty()) { @@ -133,10 +136,9 @@ if (!typeList.contains(aType)) { typeList.add(aType); } - } catch (IllegalArgumentException | UnsupportedOperationException e) { - // could be caused by the user specifying wrong - // provider name or format in the system property - LocaleServiceProviderPool.config(LocaleProviderAdapter.class, e.toString()); + } catch (IllegalArgumentException e) { + // construct a log message. + invalidTypeMessage = "Invalid locale provider adapter \"" + type + "\" ignored."; } } } @@ -144,7 +146,7 @@ defaultLocaleProviderAdapter = Type.CLDR; if (!typeList.isEmpty()) { // bona fide preference exists - if (!(typeList.contains(Type.CLDR) || (typeList.contains(Type.JRE)))) { + if (!(typeList.contains(Type.CLDR) || typeList.contains(Type.JRE))) { // Append FALLBACK as the last resort when no ResourceBundleBasedAdapter is available. typeList.add(Type.FALLBACK); defaultLocaleProviderAdapter = Type.FALLBACK; @@ -155,6 +157,15 @@ typeList.add(Type.JRE); } adapterPreference = Collections.unmodifiableList(typeList); + + // Emit logs, if any, after 'adapterPreference' is initialized which is needed + // for logging. + if (invalidTypeMessage != null) { + // could be caused by the user specifying wrong + // provider name or format in the system property + getLogger(LocaleProviderAdapter.class.getCanonicalName()) + .log(Logger.Level.INFO, invalidTypeMessage); + } } /** @@ -183,7 +194,8 @@ IllegalAccessException | InstantiationException | UnsupportedOperationException e) { - LocaleServiceProviderPool.config(LocaleProviderAdapter.class, e.toString()); + getLogger(LocaleProviderAdapter.class.getCanonicalName()) + .log(Logger.Level.INFO, e); adapterInstances.putIfAbsent(type, NONEXISTENT_ADAPTER); if (defaultLocaleProviderAdapter == type) { defaultLocaleProviderAdapter = Type.FALLBACK;