src/share/classes/javax/imageio/ImageReader.java

Print this page
rev 9293 : 8034998: Fix raw and unchecked lint warnings in javax.imageio
Reviewed-by:

@@ -791,11 +791,11 @@
     {
         return getMetadata(formatName, nodeNames, true, 0);
     }
 
     private IIOMetadata getMetadata(String formatName,
-                                    Set nodeNames,
+                                    Set<String> nodeNames,
                                     boolean wantStream,
                                     int imageIndex) throws IOException {
         if (formatName == null) {
             throw new IllegalArgumentException("formatName == null!");
         }

@@ -1063,14 +1063,14 @@
             throw new IndexOutOfBoundsException("imageIndex < getMinIndex()!");
         }
 
         BufferedImage im = read(imageIndex, param);
 
-        ArrayList thumbnails = null;
+        ArrayList<BufferedImage> thumbnails = null;
         int numThumbnails = getNumThumbnails(imageIndex);
         if (numThumbnails > 0) {
-            thumbnails = new ArrayList();
+            thumbnails = new ArrayList<>();
             for (int j = 0; j < numThumbnails; j++) {
                 thumbnails.add(readThumbnail(imageIndex, j));
             }
         }
 

@@ -1154,11 +1154,11 @@
      */
     public Iterator<IIOImage>
         readAll(Iterator<? extends ImageReadParam> params)
         throws IOException
     {
-        List output = new ArrayList();
+        List<IIOImage> output = new ArrayList<>();
 
         int imageIndex = getMinIndex();
 
         // Inform IIOReadProgressListeners we're starting a sequence
         processSequenceStarted(imageIndex);

@@ -1185,14 +1185,14 @@
                 bi = read(imageIndex, param);
             } catch (IndexOutOfBoundsException e) {
                 break;
             }
 
-            ArrayList thumbnails = null;
+            ArrayList<BufferedImage> thumbnails = null;
             int numThumbnails = getNumThumbnails(imageIndex);
             if (numThumbnails > 0) {
-                thumbnails = new ArrayList();
+                thumbnails = new ArrayList<>();
                 for (int j = 0; j < numThumbnails; j++) {
                     thumbnails.add(readThumbnail(imageIndex, j));
                 }
             }
 

@@ -1795,22 +1795,22 @@
 
     // Listeners
 
     // Add an element to a list, creating a new list if the
     // existing list is null, and return the list.
-    static List addToList(List l, Object elt) {
+    static <T> List<T> addToList(List<T> l, T elt) {
         if (l == null) {
-            l = new ArrayList();
+            l = new ArrayList<>();
         }
         l.add(elt);
         return l;
     }
 
 
     // Remove an element from a list, discarding the list if the
     // resulting list is empty, and return the list or null.
-    static List removeFromList(List l, Object elt) {
+    static <T> List<T> removeFromList(List<T> l, T elt) {
         if (l == null) {
             return l;
         }
         l.remove(elt);
         if (l.size() == 0) {

@@ -2459,14 +2459,14 @@
              * accessed via the applet class loader. So first try the context
              * class loader to locate the resource bundle.
              * If that throws MissingResourceException, then try the
              * system class loader.
              */
-            ClassLoader loader = (ClassLoader)
+            ClassLoader loader =
                 java.security.AccessController.doPrivileged(
-                   new java.security.PrivilegedAction() {
-                      public Object run() {
+                   new java.security.PrivilegedAction<ClassLoader>() {
+                      public ClassLoader run() {
                         return Thread.currentThread().getContextClassLoader();
                       }
                 });
 
             ResourceBundle bundle = null;