8033525: Fix raw and unchecked lint warnings in sun.swing.*
authordarcy
Tue, 04 Feb 2014 08:58:06 -0800
changeset 22644 965bba13a5f0
parent 22643 ba2891b3f866
child 22645 636153f07b26
8033525: Fix raw and unchecked lint warnings in sun.swing.* Reviewed-by: alexsch
jdk/src/share/classes/sun/swing/BakedArrayList.java
jdk/src/share/classes/sun/swing/FilePane.java
jdk/src/share/classes/sun/swing/SwingLazyValue.java
jdk/src/share/classes/sun/swing/SwingUtilities2.java
jdk/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java
jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
--- a/jdk/src/share/classes/sun/swing/BakedArrayList.java	Tue Feb 04 15:39:40 2014 +0000
+++ b/jdk/src/share/classes/sun/swing/BakedArrayList.java	Tue Feb 04 08:58:06 2014 -0800
@@ -44,7 +44,7 @@
  * @author Scott Violet
  */
 @SuppressWarnings("serial") // JDK-implementation class
-public class BakedArrayList extends ArrayList {
+public class BakedArrayList extends ArrayList<Object> {
     /**
      * The cached hashCode.
      */
@@ -54,7 +54,7 @@
         super(size);
     }
 
-    public BakedArrayList(java.util.List data) {
+    public BakedArrayList(java.util.List<?> data) {
         this(data.size());
         for (int counter = 0, max = data.size(); counter < max; counter++){
             add(data.get(counter));
--- a/jdk/src/share/classes/sun/swing/FilePane.java	Tue Feb 04 15:39:40 2014 +0000
+++ b/jdk/src/share/classes/sun/swing/FilePane.java	Tue Feb 04 08:58:06 2014 -0800
@@ -240,7 +240,7 @@
             }
         }
 
-        private void repaintListSelection(JList list) {
+        private void repaintListSelection(JList<?> list) {
             int[] indices = list.getSelectedIndices();
             for (int i : indices) {
                 Rectangle bounds = list.getCellBounds(i, i);
@@ -272,7 +272,7 @@
     private boolean fullRowSelection = false;
 
     private ListSelectionModel listSelectionModel;
-    private JList list;
+    private JList<?> list;
     private JTable detailsTable;
 
     private static final int COLUMN_FILENAME = 0;
@@ -332,7 +332,7 @@
                     createdViewPanel = createList();
                 }
 
-                list = (JList) findChildComponent(createdViewPanel, JList.class);
+                list = findChildComponent(createdViewPanel, JList.class);
                 if (listSelectionModel == null) {
                     listSelectionModel = list.getSelectionModel();
                     if (detailsTable != null) {
@@ -353,7 +353,7 @@
                     createdViewPanel = createDetailsView();
                 }
 
-                detailsTable = (JTable) findChildComponent(createdViewPanel, JTable.class);
+                detailsTable = findChildComponent(createdViewPanel, JTable.class);
                 detailsTable.setRowHeight(Math.max(detailsTable.getFont().getSize() + 4, 16 + 1));
                 if (listSelectionModel != null) {
                     detailsTable.setSelectionModel(listSelectionModel);
@@ -569,7 +569,7 @@
     }
 
 
-    private void updateListRowCount(JList list) {
+    private void updateListRowCount(JList<?> list) {
         if (smallIconsView) {
             list.setVisibleRowCount(getModel().getSize() / 3);
         } else {
@@ -584,7 +584,7 @@
         @SuppressWarnings("serial") // anonymous class
         final JList<Object> list = new JList<Object>() {
             public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
-                ListModel model = getModel();
+                ListModel<?> model = getModel();
                 int max = model.getSize();
                 if (prefix == null || startIndex < 0 || startIndex >= max) {
                     throw new IllegalArgumentException();
@@ -918,7 +918,7 @@
 
         public void updateComparators(ShellFolderColumnInfo [] columns) {
             for (int i = 0; i < columns.length; i++) {
-                Comparator c = columns[i].getComparator();
+                Comparator<?> c = columns[i].getComparator();
                 if (c != null) {
                     c = new DirectoriesFirstComparatorWrapper(i, c);
                 }
@@ -969,12 +969,13 @@
      * directory and file to file using the wrapped comparator.
      */
     private class DirectoriesFirstComparatorWrapper implements Comparator<File> {
-        private Comparator comparator;
+        private Comparator<Object> comparator;
         private int column;
 
-        public DirectoriesFirstComparatorWrapper(int column, Comparator comparator) {
+        @SuppressWarnings("unchecked")
+        public DirectoriesFirstComparatorWrapper(int column, Comparator<?> comparator) {
             this.column = column;
-            this.comparator = comparator;
+            this.comparator = (Comparator<Object>)comparator;
         }
 
         public int compare(File f1, File f2) {
@@ -1492,7 +1493,7 @@
     @SuppressWarnings("serial") // JDK-implementation class
     protected class FileRenderer extends DefaultListCellRenderer  {
 
-        public Component getListCellRendererComponent(JList list, Object value,
+        public Component getListCellRendererComponent(JList<?> list, Object value,
                                                       int index, boolean isSelected,
                                                       boolean cellHasFocus) {
 
@@ -1968,14 +1969,14 @@
         return fileChooserUIAccessor.getDirectory();
     }
 
-    private Component findChildComponent(Container container, Class cls) {
+    private <T> T findChildComponent(Container container, Class<T> cls) {
         int n = container.getComponentCount();
         for (int i = 0; i < n; i++) {
             Component comp = container.getComponent(i);
             if (cls.isInstance(comp)) {
-                return comp;
+                return cls.cast(comp);
             } else if (comp instanceof Container) {
-                Component c = findChildComponent((Container)comp, cls);
+                T c = findChildComponent((Container)comp, cls);
                 if (c != null) {
                     return c;
                 }
@@ -2029,7 +2030,7 @@
         public Action getApproveSelectionAction();
         public Action getChangeToParentDirectoryAction();
         public Action getNewFolderAction();
-        public MouseListener createDoubleClickListener(JList list);
+        public MouseListener createDoubleClickListener(JList<?> list);
         public ListSelectionListener createListSelectionListener();
     }
 }
--- a/jdk/src/share/classes/sun/swing/SwingLazyValue.java	Tue Feb 04 15:39:40 2014 +0000
+++ b/jdk/src/share/classes/sun/swing/SwingLazyValue.java	Tue Feb 04 08:58:06 2014 -0800
@@ -67,13 +67,13 @@
             ReflectUtil.checkPackageAccess(className);
             Class<?> c = Class.forName(className, true, null);
             if (methodName != null) {
-                Class[] types = getClassArray(args);
+                Class<?>[] types = getClassArray(args);
                 Method m = c.getMethod(methodName, types);
                 makeAccessible(m);
                 return m.invoke(c, args);
             } else {
-                Class[] types = getClassArray(args);
-                Constructor constructor = c.getConstructor(types);
+                Class<?>[] types = getClassArray(args);
+                Constructor<?> constructor = c.getConstructor(types);
                 makeAccessible(constructor);
                 return constructor.newInstance(args);
             }
@@ -96,10 +96,10 @@
         });
     }
 
-    private Class[] getClassArray(Object[] args) {
-        Class[] types = null;
+    private Class<?>[] getClassArray(Object[] args) {
+        Class<?>[] types = null;
         if (args!=null) {
-            types = new Class[args.length];
+            types = new Class<?>[args.length];
             for (int i = 0; i< args.length; i++) {
                 /* PENDING(ges): At present only the primitive types
                    used are handled correctly; this should eventually
--- a/jdk/src/share/classes/sun/swing/SwingUtilities2.java	Tue Feb 04 15:39:40 2014 +0000
+++ b/jdk/src/share/classes/sun/swing/SwingUtilities2.java	Tue Feb 04 08:58:06 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, 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
@@ -127,7 +127,7 @@
      */
     public static class AATextInfo {
 
-        private static AATextInfo getAATextInfoFromMap(Map hints) {
+        private static AATextInfo getAATextInfoFromMap(Map<java.awt.RenderingHints.Key, Object> hints) {
 
             Object aaHint   = hints.get(KEY_TEXT_ANTIALIASING);
             Object contHint = hints.get(KEY_TEXT_LCD_CONTRAST);
@@ -141,12 +141,13 @@
             }
         }
 
+        @SuppressWarnings("unchecked")
         public static AATextInfo getAATextInfo(boolean lafCondition) {
             SunToolkit.setAAFontSettingsCondition(lafCondition);
             Toolkit tk = Toolkit.getDefaultToolkit();
             Object map = tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
             if (map instanceof Map) {
-                return getAATextInfoFromMap((Map)map);
+                return getAATextInfoFromMap((Map<java.awt.RenderingHints.Key, Object>)map);
             } else {
                 return null;
             }
@@ -663,7 +664,7 @@
      * Otherwise, this method returns -1.
      * This is used to make WindowsL&F JFileChooser act like native dialogs.
      */
-    public static int loc2IndexFileList(JList list, Point point) {
+    public static int loc2IndexFileList(JList<?> list, Point point) {
         int index = list.locationToIndex(point);
         if (index != -1) {
             Object bySize = list.getClientProperty("List.isFileList");
@@ -680,11 +681,10 @@
      * Returns true if the given point is within the actual bounds of the
      * JList item at index (not just inside the cell).
      */
-    private static boolean pointIsInActualBounds(JList list, int index,
+    private static <T> boolean pointIsInActualBounds(JList<T> list, int index,
                                                 Point point) {
-        ListCellRenderer renderer = list.getCellRenderer();
-        ListModel dataModel = list.getModel();
-        Object value = dataModel.getElementAt(index);
+        ListCellRenderer<? super T> renderer = list.getCellRenderer();
+        T value = list.getModel().getElementAt(index);
         Component item = renderer.getListCellRendererComponent(list,
                           value, index, false, false);
         Dimension itemSize = item.getPreferredSize();
--- a/jdk/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java	Tue Feb 04 15:39:40 2014 +0000
+++ b/jdk/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java	Tue Feb 04 08:58:06 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2014, 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
@@ -61,7 +61,7 @@
     /**
      * User specific data.
      */
-    private Map data;
+    private Map<Object, Object> data;
 
     /**
      * Font to use if there is no matching StateInfo, or the StateInfo doesn't
@@ -106,7 +106,7 @@
             }
         }
         if (style.data != null) {
-            data = new HashMap();
+            data = new HashMap<>();
             data.putAll(style.data);
         }
         font = style.font;
@@ -124,7 +124,7 @@
      * @param data Style specific data.
      */
     public DefaultSynthStyle(Insets insets, boolean opaque,
-                             StateInfo[] states, Map data) {
+                             StateInfo[] states, Map<Object, Object> data) {
         this.insets = insets;
         this.opaque = opaque;
         this.states = states;
@@ -366,7 +366,7 @@
      *
      * @param data Style specific values
      */
-    public void setData(Map data) {
+    public void setData(Map<Object, Object> data) {
         this.data = data;
     }
 
@@ -375,7 +375,7 @@
      *
      * @return Style specific data.
      */
-    public Map getData() {
+    public Map<Object, Object> getData() {
         return data;
     }
 
@@ -402,7 +402,7 @@
     }
 
 
-    private Object getKeyFromData(Map stateData, Object key) {
+    private Object getKeyFromData(Map<Object, Object> stateData, Object key) {
           Object value = null;
           if (stateData != null) {
 
@@ -462,7 +462,7 @@
             }
         }
         if (data != null) {
-            style.data = new HashMap();
+            style.data = new HashMap<>();
             style.data.putAll(data);
         }
         return style;
@@ -570,7 +570,7 @@
         }
         if (data != null) {
             if (style.data == null) {
-                style.data = new HashMap();
+                style.data = new HashMap<>();
             }
             style.data.putAll(data);
         }
@@ -708,7 +708,7 @@
      * a component.
      */
     public static class StateInfo {
-        private Map data;
+        private Map<Object, Object> data;
         private Font font;
         private Color[] colors;
         private int state;
@@ -746,7 +746,7 @@
             this.font = info.font;
             if(info.data != null) {
                if(data == null) {
-                  data = new HashMap();
+                  data = new HashMap<>();
                }
                data.putAll(info.data);
             }
@@ -756,11 +756,11 @@
             }
         }
 
-        public Map getData() {
+        public Map<Object, Object> getData() {
             return data;
         }
 
-        public void setData(Map data) {
+        public void setData(Map<Object, Object> data) {
             this.data = data;
         }
 
@@ -836,7 +836,7 @@
             }
             if(data != null) {
                 if(info.data == null) {
-                    info.data = new HashMap();
+                    info.data = new HashMap<>();
                 }
                 info.data.putAll(data);
             }
--- a/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Tue Feb 04 15:39:40 2014 +0000
+++ b/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java	Tue Feb 04 08:58:06 2014 -0800
@@ -175,7 +175,7 @@
             return SynthFileChooserUIImpl.this.getNewFolderAction();
         }
 
-        public MouseListener createDoubleClickListener(JList list) {
+        public MouseListener createDoubleClickListener(JList<?> list) {
             return SynthFileChooserUIImpl.this.createDoubleClickListener(getFileChooser(),
                                                                      list);
         }
@@ -563,7 +563,7 @@
         if (currentDirectory != null) {
             JComponent cb = getDirectoryComboBox();
             if (cb instanceof JComboBox) {
-                ComboBoxModel model = ((JComboBox)cb).getModel();
+                ComboBoxModel<?> model = ((JComboBox)cb).getModel();
                 if (model instanceof DirectoryComboBoxModel) {
                     ((DirectoryComboBoxModel)model).addItem(currentDirectory);
                 }