diff --git a/src/share/classes/java/util/Currency.java b/src/share/classes/java/util/Currency.java index dc9271ae92d00787a45184cc3fc10808395f996a..87b7e01b75b38632d3c6219bfadf7e87ea204b86 100644 --- a/src/share/classes/java/util/Currency.java +++ b/src/share/classes/java/util/Currency.java @@ -189,7 +189,7 @@ public final class Currency implements Serializable { private static final int VALID_FORMAT_VERSION = 1; static { - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String homeDir = System.getProperty("java.home"); try { @@ -431,7 +431,9 @@ public final class Currency implements Serializable { } } - return (Set) available.clone(); + @SuppressWarnings("unchecked") + Set result = (Set) available.clone(); + return result; } /** diff --git a/src/share/classes/sun/util/LocaleServiceProviderPool.java b/src/share/classes/sun/util/LocaleServiceProviderPool.java index c45100d75083e601102ae8940e4bd8806c2a0829..349ce56e90e88cf1be8f1aa7a81dc3c4220597b5 100644 --- a/src/share/classes/sun/util/LocaleServiceProviderPool.java +++ b/src/share/classes/sun/util/LocaleServiceProviderPool.java @@ -58,7 +58,7 @@ public final class LocaleServiceProviderPool { * A Map that holds singleton instances of this class. Each instance holds a * set of provider implementations of a particular locale sensitive service. */ - private static ConcurrentMap poolOfPools = + private static ConcurrentMap, LocaleServiceProviderPool> poolOfPools = new ConcurrentHashMap<>(); /** @@ -147,6 +147,10 @@ public final class LocaleServiceProviderPool { /** * Lazy loaded set of available locales. * Loading all locales is a very long operation. + * + * We know "providerClasses" contains classes that extends LocaleServiceProvider, + * but generic array creation is not allowed, thus the "unchecked" warning + * is suppressed here. */ private static class AllAvailableLocales { /** @@ -156,7 +160,9 @@ public final class LocaleServiceProviderPool { static final Locale[] allAvailableLocales; static { - Class[] providerClasses = { + @SuppressWarnings("unchecked") + Class[] providerClasses = + (Class[]) new Class[] { java.text.spi.BreakIteratorProvider.class, java.text.spi.CollatorProvider.class, java.text.spi.DateFormatProvider.class, @@ -174,7 +180,7 @@ public final class LocaleServiceProviderPool { all.add(getLookupLocale(locale)); } - for (Class providerClass : providerClasses) { + for (Class providerClass : providerClasses) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(providerClass); all.addAll(pool.getProviderLocales()); @@ -355,7 +361,6 @@ public final class LocaleServiceProviderPool { } Locale bundleLocale = (bundle != null ? bundle.getLocale() : null); List lookupLocales = getLookupLocales(locale); - P lsp; S providersObj = null; // check whether a provider has an implementation that's closer @@ -375,7 +380,9 @@ public final class LocaleServiceProviderPool { } } if (provLoc.contains(current)) { - lsp = (P)findProvider(current); + // It is safe to assume that findProvider() returns the instance of type P. + @SuppressWarnings("unchecked") + P lsp = (P)findProvider(current); if (lsp != null) { providersObj = getter.getObject(lsp, locale, key, params); if (providersObj != null) { @@ -397,7 +404,9 @@ public final class LocaleServiceProviderPool { // JRE has it. return null; } else { - lsp = (P)findProvider(bundleLocale); + // It is safe to assume that findProvider() returns the instance of type P. + @SuppressWarnings("unchecked") + P lsp = (P)findProvider(bundleLocale); if (lsp != null) { providersObj = getter.getObject(lsp, locale, key, params); if (providersObj != null) { diff --git a/src/share/classes/sun/util/resources/LocaleData.java b/src/share/classes/sun/util/resources/LocaleData.java index a082a601dd02041b20b7402e2e98b3fcead101a2..ac8fdd27c86665f548bc69111d88bc82fb6d875d 100644 --- a/src/share/classes/sun/util/resources/LocaleData.java +++ b/src/share/classes/sun/util/resources/LocaleData.java @@ -137,8 +137,8 @@ public class LocaleData { } private static ResourceBundle getBundle(final String baseName, final Locale locale) { - return (ResourceBundle) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged(new PrivilegedAction() { + public ResourceBundle run() { return ResourceBundle. getBundle(baseName, locale, LocaleDataResourceBundleControl.getRBControlInstance());