7117469: Warning cleanup for j.u.Currency and j.u.Locale related classes

Reviewed-by: okutsu, smarks
This commit is contained in:
Naoto Sato 2011-12-05 17:08:52 -08:00
parent 95afca84d2
commit 272537ad66
3 changed files with 21 additions and 10 deletions
jdk/src/share/classes

@ -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<Object>() {
public Object run() {
String homeDir = System.getProperty("java.home");
try {
@ -431,7 +431,9 @@ public final class Currency implements Serializable {
}
}
return (Set<Currency>) available.clone();
@SuppressWarnings("unchecked")
Set<Currency> result = (Set<Currency>) available.clone();
return result;
}
/**

@ -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<Class, LocaleServiceProviderPool> poolOfPools =
private static ConcurrentMap<Class<? extends LocaleServiceProvider>, 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<LocaleServiceProvider>[] providerClasses =
(Class<LocaleServiceProvider>[]) 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<LocaleServiceProvider> 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<Locale> 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) {

@ -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<ResourceBundle>() {
public ResourceBundle run() {
return ResourceBundle.
getBundle(baseName, locale,
LocaleDataResourceBundleControl.getRBControlInstance());