src/share/classes/java/util/ResourceBundle.java

Print this page
rev 4788 : Fix bunch of generics warnings

@@ -292,11 +292,12 @@
         = new ConcurrentHashMap<>(INITIAL_CACHE_SIZE);
 
     /**
      * Queue for reference objects referring to class loaders or bundles.
      */
-    private static final ReferenceQueue referenceQueue = new ReferenceQueue();
+    private static final ReferenceQueue<Object> referenceQueue =
+        new ReferenceQueue<>();
 
     /**
      * The parent bundle of this bundle.
      * The parent bundle is searched by {@link #getObject getObject}
      * when this bundle does not contain a particular resource.

@@ -414,13 +415,13 @@
      * Automatic determination of the ClassLoader to be used to load
      * resources on behalf of the client.  N.B. The client is getLoader's
      * caller's caller.
      */
     private static ClassLoader getLoader() {
-        Class[] stack = getClassContext();
+        Class<?>[] stack = getClassContext();
         /* Magic number 2 identifies our caller's caller */
-        Class c = stack[2];
+        Class<?> c = stack[2];
         ClassLoader cl = (c == null) ? null : c.getClassLoader();
         if (cl == null) {
             // When the caller's loader is the boot class loader, cl is null
             // here. In that case, ClassLoader.getSystemClassLoader() may
             // return the same class loader that the application is

@@ -431,11 +432,11 @@
             cl = RBClassLoader.INSTANCE;
         }
         return cl;
     }
 
-    private static native Class[] getClassContext();
+    private static native Class<?>[] getClassContext();
 
     /**
      * A wrapper of ClassLoader.getSystemClassLoader().
      */
     private static class RBClassLoader extends ClassLoader {

@@ -671,11 +672,11 @@
      */
     private static final class LoaderReference extends WeakReference<ClassLoader>
                                                implements CacheKeyReference {
         private CacheKey cacheKey;
 
-        LoaderReference(ClassLoader referent, ReferenceQueue q, CacheKey key) {
+        LoaderReference(ClassLoader referent, ReferenceQueue<Object> q, CacheKey key) {
             super(referent, q);
             cacheKey = key;
         }
 
         public CacheKey getCacheKey() {

@@ -689,11 +690,11 @@
      */
     private static final class BundleReference extends SoftReference<ResourceBundle>
                                                implements CacheKeyReference {
         private CacheKey cacheKey;
 
-        BundleReference(ResourceBundle referent, ReferenceQueue q, CacheKey key) {
+        BundleReference(ResourceBundle referent, ReferenceQueue<Object> q, CacheKey key) {
             super(referent, q);
             cacheKey = key;
         }
 
         public CacheKey getCacheKey() {

@@ -1329,11 +1330,11 @@
 
     /**
      * Checks if the given <code>List</code> is not null, not empty,
      * not having null in its elements.
      */
-    private static final boolean checkList(List a) {
+    private static final boolean checkList(List<?> a) {
         boolean valid = (a != null && a.size() != 0);
         if (valid) {
             int size = a.size();
             for (int i = 0; valid && i < size; i++) {
                 valid = (a.get(i) != null);

@@ -2560,17 +2561,16 @@
                     throws IllegalAccessException, InstantiationException, IOException {
             String bundleName = toBundleName(baseName, locale);
             ResourceBundle bundle = null;
             if (format.equals("java.class")) {
                 try {
-                    Class<? extends ResourceBundle> bundleClass
-                        = (Class<? extends ResourceBundle>)loader.loadClass(bundleName);
+                    Class<?> bundleClass = loader.loadClass(bundleName);
 
                     // If the class isn't a ResourceBundle subclass, throw a
                     // ClassCastException.
                     if (ResourceBundle.class.isAssignableFrom(bundleClass)) {
-                        bundle = bundleClass.newInstance();
+                        bundle = (ResourceBundle)bundleClass.newInstance();
                     } else {
                         throw new ClassCastException(bundleClass.getName()
                                      + " cannot be cast to ResourceBundle");
                     }
                 } catch (ClassNotFoundException e) {