Hi,

here another patch to remove warnings in the gtk package.

When compiling with
-Xlint -J-Xms80m -J-Xmx256m -Xlint:-serial -Xlint:-deprecation 
-Xlint:-fallthrough -Xmaxwarns 
2300
this patch reduces the number of reported warnings from 201 to 112.

Again, I tried only to change things related to the warnings and not to change 
any public or protected APIs in public or protected classes in this patch.

At many places I tried to add type parameters as meaningful as possible, 
but with some cases I just used Object, if a more meaningful type 
parameter was not so trivial. You might want to refactor this if needed. 
(Though everything should work as it is.)

-Florian
diff -r 2055acc62a85 src/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java	Thu Sep 04 15:15:24 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java	Thu Oct 09 01:09:43 2008 +0200
@@ -799,9 +799,9 @@ class GTKColorChooserPanel extends Abstr
             Graphics g = triangleImage.getGraphics();
             g.setColor(new Color(0, 0, 0, 0));
             g.fillRect(0, 0, a, a);
-            g.translate((int)(a / 2), 0);
+            g.translate(a / 2, 0);
             paintTriangle(g, triangleSize, getColor());
-            g.translate((int)(-a / 2), 0);
+            g.translate(-a / 2, 0);
             g.dispose();
 
             g = wheelImage.getGraphics();
@@ -897,7 +897,7 @@ class GTKColorChooserPanel extends Abstr
                 return false;
             }
             // Rotate to origin and and verify x is valid.
-            int triangleSize = (int)innerR * 3 / 2;
+            int triangleSize = innerR * 3 / 2;
             double x1 = Math.cos(angle) * x - Math.sin(angle) * y;
             double y1 = Math.sin(angle) * x + Math.cos(angle) * y;
             if (x1 < -(innerR / 2)) {
@@ -960,7 +960,7 @@ class GTKColorChooserPanel extends Abstr
          */
         private void setSaturationAndBrightness(float s, float b) {
             int innerR = getTriangleCircumscribedRadius();
-            int triangleSize = (int)innerR * 3 / 2;
+            int triangleSize = innerR * 3 / 2;
             double x = b * triangleSize;
             double maxY = x * Math.tan(Math.toRadians(30.0));
             double y = 2 * maxY * s - maxY;
@@ -1165,12 +1165,12 @@ class GTKColorChooserPanel extends Abstr
             if (angle < PI_3) {
                 if (y < 0) {
                     // FFFF00 - FF0000
-                    rgb = 0xFF0000 | (int)Math.min(255,
+                    rgb = 0xFF0000 | Math.min(255,
                                            (int)(255 * angle / PI_3)) << 8;
                 }
                 else {
                     // FF0000 - FF00FF
-                    rgb = 0xFF0000 | (int)Math.min(255,
+                    rgb = 0xFF0000 | Math.min(255,
                                            (int)(255 * angle / PI_3));
                 }
             }
@@ -1178,12 +1178,12 @@ class GTKColorChooserPanel extends Abstr
                 angle -= PI_3;
                 if (y < 0) {
                     // 00FF00 - FFFF00
-                    rgb = 0x00FF00 | (int)Math.max(0, 255 -
+                    rgb = 0x00FF00 | Math.max(0, 255 -
                                            (int)(255 * angle / PI_3)) << 16;
                 }
                 else {
                     // FF00FF - 0000FF
-                    rgb = 0x0000FF | (int)Math.max(0, 255 -
+                    rgb = 0x0000FF | Math.max(0, 255 -
                                            (int)(255 * angle / PI_3)) << 16;
                 }
             }
@@ -1191,12 +1191,12 @@ class GTKColorChooserPanel extends Abstr
                 angle -= 2 * PI_3;
                 if (y < 0) {
                     // 00FFFF - 00FF00
-                    rgb = 0x00FF00 | (int)Math.min(255,
+                    rgb = 0x00FF00 | Math.min(255,
                                            (int)(255 * angle / PI_3));
                 }
                 else {
                     // 0000FF - 00FFFF
-                    rgb = 0x0000FF | (int)Math.min(255,
+                    rgb = 0x0000FF | Math.min(255,
                                            (int)(255 * angle / PI_3)) << 8;
                 }
             }
diff -r 2055acc62a85 src/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java	Thu Sep 04 15:15:24 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java	Thu Oct 09 01:09:43 2008 +0200
@@ -112,7 +112,7 @@ class GTKEngine {
     }
 
 
-    private static HashMap regionToWidgetTypeMap;
+    private static HashMap<Region, Object> regionToWidgetTypeMap;
     private ImageCache cache = new ImageCache(CACHE_SIZE);
     private int x0, y0, w0, h0;
     private Graphics graphics;
@@ -178,7 +178,7 @@ class GTKEngine {
         Toolkit.getDefaultToolkit();
 
         // Initialize regionToWidgetTypeMap
-        regionToWidgetTypeMap = new HashMap(50);
+        regionToWidgetTypeMap = new HashMap<Region, Object>(50);
         regionToWidgetTypeMap.put(Region.ARROW_BUTTON, new WidgetType[] {
             WidgetType.SPINNER_ARROW_BUTTON,
             WidgetType.COMBO_BOX_ARROW_BUTTON,
diff -r 2055acc62a85 src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java	Thu Sep 04 15:15:24 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java	Thu Oct 09 01:09:43 2008 +0200
@@ -148,7 +148,7 @@ class GTKFileChooserUI extends SynthFile
             directoryList : fileList;
         Object[] files = list.getSelectedValues();
         int len = files.length;
-        Vector result = new Vector(len + 1);
+        Vector<String> result = new Vector<String>(len + 1);
 
         // we return all selected file names
         for (int i = 0; i < len; i++) {
@@ -425,7 +425,7 @@ class GTKFileChooserUI extends SynthFile
                             setDirectorySelected(true);
                             setDirectory(((File)objects[0]));
                         } else {
-                            ArrayList fList = new ArrayList(objects.length);
+                            ArrayList<File> fList = new ArrayList<File>(objects.length);
                             for (int i = 0; i < objects.length; i++) {
                                 File f = (File)objects[i];
                                 if ((chooser.isFileSelectionEnabled() && f.isFile())
@@ -434,7 +434,7 @@ class GTKFileChooserUI extends SynthFile
                                 }
                             }
                             if (fList.size() > 0) {
-                                files = (File[])fList.toArray(new File[fList.size()]);
+                                files = fList.toArray(new File[fList.size()]);
                             }
                             setDirectorySelected(false);
                         }
@@ -671,9 +671,9 @@ class GTKFileChooserUI extends SynthFile
 
         pathFieldLabel.setLabelFor(fileNameTextField);
 
-        Set forwardTraversalKeys = fileNameTextField.getFocusTraversalKeys(
+        Set<AWTKeyStroke> forwardTraversalKeys = fileNameTextField.getFocusTraversalKeys(
             KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
-        forwardTraversalKeys = new HashSet(forwardTraversalKeys);
+        forwardTraversalKeys = new HashSet<AWTKeyStroke>(forwardTraversalKeys);
         forwardTraversalKeys.remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
         fileNameTextField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardTraversalKeys);
 
@@ -895,10 +895,10 @@ class GTKFileChooserUI extends SynthFile
 
     private class GTKDirectoryModel extends BasicDirectoryModel {
         FileSystemView fsv;
-        private Comparator fileComparator = new Comparator() {
-            public int compare(Object o, Object o1) {
-                return fsv.getSystemDisplayName((File) o).compareTo
-                      (fsv.getSystemDisplayName((File) o1));
+        private Comparator<File> fileComparator = new Comparator<File>() {
+            public int compare(File o, File o1) {
+                return fsv.getSystemDisplayName(o).compareTo
+                      (fsv.getSystemDisplayName(o1));
             }
         };
 
diff -r 2055acc62a85 src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Thu Sep 04 15:15:24 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Thu Oct 09 01:09:43 2008 +0200
@@ -299,7 +299,7 @@ class GTKPainter extends SynthPainter {
             // Paint the default indicator
             GTKStyle style = (GTKStyle)context.getStyle();
             if (defaultCapable && !toolButton) {
-                Insets defaultInsets = (Insets)style.getClassSpecificInsetsValue(
+                Insets defaultInsets = style.getClassSpecificInsetsValue(
                         context, "default-border",
                         GTKStyle.BUTTON_DEFAULT_BORDER_INSETS);
 
diff -r 2055acc62a85 src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java	Thu Sep 04 15:15:24 2008 +0400
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java	Thu Oct 09 01:09:43 2008 +0200
@@ -124,7 +124,7 @@ class Metacity implements SynthConstants
         }
 
         // Initialize constants
-        variables = new HashMap();
+        variables = new HashMap<String, Integer>();
         NodeList nodes = xmlDoc.getElementsByTagName("constant");
         int n = nodes.getLength();
         for (int i = 0; i < n; i++) {
@@ -144,14 +144,14 @@ class Metacity implements SynthConstants
         }
 
         // Cache frame geometries
-        frameGeometries = new HashMap();
+        frameGeometries = new HashMap<String, Map<String, Object>>();
         nodes = xmlDoc.getElementsByTagName("frame_geometry");
         n = nodes.getLength();
         for (int i = 0; i < n; i++) {
             Node node = nodes.item(i);
             String name = getStringAttr(node, "name");
             if (name != null) {
-                HashMap<String, Object> gm = new HashMap();
+                HashMap<String, Object> gm = new HashMap<String, Object>();
                 frameGeometries.put(name, gm);
 
                 String parentGM = getStringAttr(node, "parent");
@@ -458,7 +458,7 @@ class Metacity implements SynthConstants
 
 
 
-    private static class Privileged implements PrivilegedAction {
+    private static class Privileged implements PrivilegedAction<Object> {
         private static int GET_THEME_DIR  = 0;
         private static int GET_USER_THEME = 1;
         private static int GET_IMAGE      = 2;
@@ -598,7 +598,7 @@ class Metacity implements SynthConstants
         g2.setComposite(oldComp);
     }
 
-    private HashMap<String, Image> images = new HashMap();
+    private HashMap<String, Image> images = new HashMap<String, Image>();
 
     protected Image getImage(String key, Color c) {
         Image image = images.get(key+"-"+c.getRGB());
@@ -1530,8 +1530,8 @@ class Metacity implements SynthConstants
                 DocumentBuilderFactory.newInstance().newDocumentBuilder();
         }
         InputStream inputStream =
-            (InputStream)AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+            AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+                public InputStream run() {
                     try {
                         return new BufferedInputStream(xmlFile.openStream());
                     } catch (IOException ex) {
@@ -1551,7 +1551,7 @@ class Metacity implements SynthConstants
     protected Node[] getNodesByName(Node parent, String name) {
         NodeList nodes = parent.getChildNodes(); // ElementNode
         int n = nodes.getLength();
-        ArrayList<Node> list = new ArrayList();
+        ArrayList<Node> list = new ArrayList<Node>();
         for (int i=0; i < n; i++) {
             Node node = nodes.item(i);
             if (name.equals(node.getNodeName())) {
@@ -1603,7 +1603,7 @@ class Metacity implements SynthConstants
                             String aValue = attrs[a * 2 + 1];
                             Node attr = nodeAttrs.getNamedItem(aName);
                             if (attr == null ||
-                                aValue != null && !aValue.equals((String)attr.getNodeValue())) {
+                                aValue != null && !aValue.equals(attr.getNodeValue())) {
                                 matches = false;
                                 break;
                             }
@@ -1642,7 +1642,7 @@ class Metacity implements SynthConstants
 
     protected String getStringAttr(NamedNodeMap attrs, String name) {
         Node item = attrs.getNamedItem(name);
-        return (item != null) ? (String)item.getNodeValue() : null;
+        return (item != null) ? item.getNodeValue() : null;
     }
 
     protected boolean getBooleanAttr(Node node, String name, boolean fallback) {

Reply via email to