8022184: Fix static , Raw warnings in classes belonging to java.awt
authorart
Mon, 02 Sep 2013 16:48:51 +0400
changeset 20107 18e644411f0b
parent 20106 5d5f2c72f262
child 20108 e466f9fb7f00
8022184: Fix static , Raw warnings in classes belonging to java.awt Reviewed-by: art, anthony Contributed-by: Srikalyan Chandrashekar <srikalyan.chandrashekar@oracle.com>
jdk/src/share/classes/java/awt/AWTKeyStroke.java
jdk/src/share/classes/java/awt/CardLayout.java
jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java
jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java
jdk/src/share/classes/java/awt/GradientPaintContext.java
jdk/src/share/classes/java/awt/GraphicsEnvironment.java
jdk/src/share/classes/java/awt/KeyboardFocusManager.java
jdk/src/share/classes/java/awt/SequencedEvent.java
jdk/src/share/classes/java/awt/TexturePaintContext.java
jdk/src/share/classes/java/awt/WaitDispatchSupport.java
--- a/jdk/src/share/classes/java/awt/AWTKeyStroke.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/AWTKeyStroke.java	Mon Sep 02 16:48:51 2013 +0400
@@ -67,7 +67,7 @@
 public class AWTKeyStroke implements Serializable {
     static final long serialVersionUID = -6430539691155161871L;
 
-    private static Map modifierKeywords;
+    private static Map<String, Integer> modifierKeywords;
     /**
      * Associates VK_XXX (as a String) with code (as Integer). This is
      * done to avoid the overhead of the reflective call to find the
@@ -85,8 +85,8 @@
      * AWTKeyStroke class.
      * Must be called under locked AWTKeyStro
      */
-    private static Class getAWTKeyStrokeClass() {
-        Class clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
+    private static Class<AWTKeyStroke> getAWTKeyStrokeClass() {
+        Class<AWTKeyStroke> clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
         if (clazz == null) {
             clazz = AWTKeyStroke.class;
             AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class);
@@ -182,7 +182,7 @@
             throw new IllegalArgumentException("subclass cannot be null");
         }
         synchronized (AWTKeyStroke.class) {
-            Class keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
+            Class<AWTKeyStroke> keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
             if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){
                 // Already registered
                 return;
@@ -229,8 +229,8 @@
      */
     private static Constructor getCtor(final Class clazz)
     {
-        Object ctor = AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        Constructor ctor = AccessController.doPrivileged(new PrivilegedAction<Constructor>() {
+            public Constructor run() {
                 try {
                     Constructor ctor = clazz.getDeclaredConstructor((Class[]) null);
                     if (ctor != null) {
@@ -249,17 +249,17 @@
     private static synchronized AWTKeyStroke getCachedStroke
         (char keyChar, int keyCode, int modifiers, boolean onKeyRelease)
     {
-        Map cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY);
+        Map<AWTKeyStroke, AWTKeyStroke> cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY);
         AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY);
 
         if (cache == null) {
-            cache = new HashMap();
+            cache = new HashMap<>();
             AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache);
         }
 
         if (cacheKey == null) {
             try {
-                Class clazz = getAWTKeyStrokeClass();
+                Class<AWTKeyStroke> clazz = getAWTKeyStrokeClass();
                 cacheKey = (AWTKeyStroke)getCtor(clazz).newInstance((Object[]) null);
                 AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey);
             } catch (InstantiationException e) {
@@ -513,7 +513,7 @@
 
         synchronized (AWTKeyStroke.class) {
             if (modifierKeywords == null) {
-                Map uninitializedMap = new HashMap(8, 1.0f);
+                Map<String, Integer> uninitializedMap = new HashMap<>(8, 1.0f);
                 uninitializedMap.put("shift",
                                      Integer.valueOf(InputEvent.SHIFT_DOWN_MASK
                                                      |InputEvent.SHIFT_MASK));
@@ -861,12 +861,12 @@
 }
 
 class VKCollection {
-    Map code2name;
-    Map name2code;
+    Map<Integer, String> code2name;
+    Map<String, Integer> name2code;
 
     public VKCollection() {
-        code2name = new HashMap();
-        name2code = new HashMap();
+        code2name = new HashMap<>();
+        name2code = new HashMap<>();
     }
 
     public synchronized void put(String name, Integer code) {
--- a/jdk/src/share/classes/java/awt/CardLayout.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/CardLayout.java	Mon Sep 02 16:48:51 2013 +0400
@@ -66,7 +66,7 @@
      * pairs of components and their names.
      * @see java.util.Vector
      */
-    Vector vector = new Vector();
+    Vector<Card> vector = new Vector<>();
 
     /*
      * A pair of Component and String that represents its name.
@@ -570,10 +570,10 @@
 
         if (f.defaulted("vector")) {
             //  pre-1.4 stream
-            Hashtable tab = (Hashtable)f.get("tab", null);
-            vector = new Vector();
+            Hashtable<String, Component> tab = (Hashtable)f.get("tab", null);
+            vector = new Vector<>();
             if (tab != null && !tab.isEmpty()) {
-                for (Enumeration e = tab.keys() ; e.hasMoreElements() ; ) {
+                for (Enumeration<String> e = tab.keys() ; e.hasMoreElements() ; ) {
                     String key = (String)e.nextElement();
                     Component comp = (Component)tab.get(key);
                     vector.add(new Card(key, comp));
@@ -594,7 +594,7 @@
     private void writeObject(ObjectOutputStream s)
         throws IOException
     {
-        Hashtable tab = new Hashtable();
+        Hashtable<String, Component> tab = new Hashtable<>();
         int ncomponents = vector.size();
         for (int i = 0; i < ncomponents; i++) {
             Card card = (Card)vector.get(i);
--- a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java	Mon Sep 02 16:48:51 2013 +0400
@@ -85,7 +85,7 @@
      * list should be reused if possible.
      */
     transient private Container cachedRoot;
-    transient private List cachedCycle;
+    transient private List<Component> cachedCycle;
 
     /*
      * We suppose to use getFocusTraversalCycle & getComponentIndex methods in order
@@ -111,7 +111,7 @@
         return cycle.indexOf(aComponent);
     }
 
-    private void enumerateCycle(Container container, List cycle) {
+    private void enumerateCycle(Container container, List<Component> cycle) {
         if (!(container.isVisible() && container.isDisplayable())) {
             return;
         }
--- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java	Mon Sep 02 16:48:51 2013 +0400
@@ -808,13 +808,13 @@
             }
         }
         boolean stopPostProcessing = false;
-        java.util.List processors = getKeyEventPostProcessors();
+        java.util.List<KeyEventPostProcessor> processors = getKeyEventPostProcessors();
         if (processors != null) {
-            for (java.util.Iterator iter = processors.iterator();
+            for (java.util.Iterator<KeyEventPostProcessor> iter = processors.iterator();
                  !stopPostProcessing && iter.hasNext(); )
             {
-                stopPostProcessing = (((KeyEventPostProcessor)(iter.next())).
-                            postProcessKeyEvent(e));
+                stopPostProcessing = iter.next().
+                            postProcessKeyEvent(e);
             }
         }
         if (!stopPostProcessing) {
@@ -1059,12 +1059,12 @@
             return true;
         }
 
-        java.util.List dispatchers = getKeyEventDispatchers();
+        java.util.List<KeyEventDispatcher> dispatchers = getKeyEventDispatchers();
         if (dispatchers != null) {
-            for (java.util.Iterator iter = dispatchers.iterator();
+            for (java.util.Iterator<KeyEventDispatcher> iter = dispatchers.iterator();
                  iter.hasNext(); )
              {
-                 if (((KeyEventDispatcher)(iter.next())).
+                 if (iter.next().
                      dispatchKeyEvent(ke))
                  {
                      return true;
@@ -1131,7 +1131,7 @@
                 oppStroke = AWTKeyStroke.getAWTKeyStroke(stroke.getKeyCode(),
                                                  stroke.getModifiers(),
                                                  !stroke.isOnKeyRelease());
-            Set toTest;
+            Set<AWTKeyStroke> toTest;
             boolean contains, containsOpp;
 
             toTest = focusedComponent.getFocusTraversalKeys(
--- a/jdk/src/share/classes/java/awt/GradientPaintContext.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/GradientPaintContext.java	Mon Sep 02 16:48:51 2013 +0400
@@ -41,7 +41,7 @@
         new DirectColorModel(24, 0x000000ff, 0x0000ff00, 0x00ff0000);
 
     static ColorModel cachedModel;
-    static WeakReference cached;
+    static WeakReference<Raster> cached;
 
     static synchronized Raster getCachedRaster(ColorModel cm, int w, int h) {
         if (cm == cachedModel) {
@@ -76,7 +76,7 @@
             }
         }
         cachedModel = cm;
-        cached = new WeakReference(ras);
+        cached = new WeakReference<>(ras);
     }
 
     double x1;
--- a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java	Mon Sep 02 16:48:51 2013 +0400
@@ -95,18 +95,18 @@
         String nm = AccessController.doPrivileged(new GetPropertyAction("java.awt.graphicsenv", null));
         try {
 //          long t0 = System.currentTimeMillis();
-            Class geCls;
+            Class<GraphicsEnvironment> geCls;
             try {
                 // First we try if the bootclassloader finds the requested
                 // class. This way we can avoid to run in a privileged block.
-                geCls = Class.forName(nm);
+                geCls = (Class<GraphicsEnvironment>)Class.forName(nm);
             } catch (ClassNotFoundException ex) {
                 // If the bootclassloader fails, we try again with the
                 // application classloader.
                 ClassLoader cl = ClassLoader.getSystemClassLoader();
-                geCls = Class.forName(nm, true, cl);
+                geCls = (Class<GraphicsEnvironment>)Class.forName(nm, true, cl);
             }
-            ge = (GraphicsEnvironment) geCls.newInstance();
+            ge = geCls.newInstance();
 //          long t1 = System.currentTimeMillis();
 //          System.out.println("GE creation took " + (t1-t0)+ "ms.");
             if (isHeadless()) {
@@ -161,7 +161,7 @@
     private static boolean getHeadlessProperty() {
         if (headless == null) {
             java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
+            new java.security.PrivilegedAction<Object>() {
                 public Object run() {
                     String nm = System.getProperty("java.awt.headless");
 
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java	Mon Sep 02 16:48:51 2013 +0400
@@ -348,7 +348,7 @@
      * Component of those Windows that has no such array of its own explicitly
      * set.
      */
-    private Set[] defaultFocusTraversalKeys = new Set[4];
+    private Set<AWTKeyStroke>[] defaultFocusTraversalKeys = new Set[4];
 
     /**
      * The current focus cycle root. If the focus owner is itself a focus cycle
@@ -376,7 +376,7 @@
      * KeyEventDispatchers are registered, this field may be null or refer to
      * a List of length 0.
      */
-    private java.util.LinkedList keyEventDispatchers;
+    private java.util.LinkedList<KeyEventDispatcher> keyEventDispatchers;
 
     /**
      * This KeyboardFocusManager's KeyEventPostProcessor chain. The List does
@@ -385,12 +385,12 @@
      * If no other KeyEventPostProcessors are registered, this field may be
      * null or refer to a List of length 0.
      */
-    private java.util.LinkedList keyEventPostProcessors;
+    private java.util.LinkedList<KeyEventPostProcessor> keyEventPostProcessors;
 
     /**
      * Maps Windows to those Windows' most recent focus owners.
      */
-    private static java.util.Map mostRecentFocusOwners = new WeakHashMap();
+    private static java.util.Map<Window, WeakReference<Component>> mostRecentFocusOwners = new WeakHashMap<>();
 
     /**
      * We cache the permission used to verify that the calling thread is
@@ -431,7 +431,7 @@
      */
     public KeyboardFocusManager() {
         for (int i = 0; i < TRAVERSAL_KEY_LENGTH; i++) {
-            Set work_set = new HashSet();
+            Set<AWTKeyStroke> work_set = new HashSet<>();
             for (int j = 0; j < defaultFocusTraversalKeyStrokes[i].length; j++) {
                 work_set.add(defaultFocusTraversalKeyStrokes[i][j]);
             }
@@ -1125,7 +1125,7 @@
             throw new IllegalArgumentException("cannot set null Set of default focus traversal keys");
         }
 
-        Set oldKeys;
+        Set<AWTKeyStroke> oldKeys;
 
         synchronized (this) {
             for (AWTKeyStroke keystroke : keystrokes) {
@@ -1153,7 +1153,7 @@
 
             oldKeys = defaultFocusTraversalKeys[id];
             defaultFocusTraversalKeys[id] =
-                Collections.unmodifiableSet(new HashSet(keystrokes));
+                Collections.unmodifiableSet(new HashSet<>(keystrokes));
         }
 
         firePropertyChange(defaultFocusTraversalKeyPropertyNames[id],
@@ -1699,7 +1699,7 @@
         if (dispatcher != null) {
             synchronized (this) {
                 if (keyEventDispatchers == null) {
-                    keyEventDispatchers = new java.util.LinkedList();
+                    keyEventDispatchers = new java.util.LinkedList<>();
                 }
                 keyEventDispatchers.add(dispatcher);
             }
@@ -1787,7 +1787,7 @@
         if (processor != null) {
             synchronized (this) {
                 if (keyEventPostProcessors == null) {
-                    keyEventPostProcessors = new java.util.LinkedList();
+                    keyEventPostProcessors = new java.util.LinkedList<>();
                 }
                 keyEventPostProcessors.add(processor);
             }
@@ -1865,9 +1865,9 @@
         // of Component.parent fields.  Since WeakHasMap refers to its
         // values strongly, we need to break the strong link from the
         // value (component) back to its key (window).
-        WeakReference weakValue = null;
+        WeakReference<Component> weakValue = null;
         if (component != null) {
-            weakValue = new WeakReference(component);
+            weakValue = new WeakReference<>(component);
         }
         mostRecentFocusOwners.put(window, weakValue);
     }
@@ -1906,7 +1906,7 @@
      * javax.swing.JComponent.runInputVerifier() using reflection.
      */
     static synchronized Component getMostRecentFocusOwner(Window window) {
-        WeakReference weakValue =
+        WeakReference<Component> weakValue =
             (WeakReference)mostRecentFocusOwners.get(window);
         return weakValue == null ? null : (Component)weakValue.get();
     }
@@ -2649,11 +2649,11 @@
                 Component lastFocusOwner = null;
                 Component currentFocusOwner = null;
 
-                for (Iterator iter = localLightweightRequests.iterator(); iter.hasNext(); ) {
+                for (Iterator<KeyboardFocusManager.LightweightFocusRequest> iter = localLightweightRequests.iterator(); iter.hasNext(); ) {
 
                     currentFocusOwner = manager.getGlobalFocusOwner();
                     LightweightFocusRequest lwFocusRequest =
-                        (LightweightFocusRequest)iter.next();
+                        iter.next();
 
                     /*
                      * WARNING: This is based on DKFM's logic solely!
@@ -2978,12 +2978,12 @@
             if (hwFocusRequest != null) {
                 heavyweightRequests.removeFirst();
                 if (hwFocusRequest.lightweightRequests != null) {
-                    for (Iterator lwIter = hwFocusRequest.lightweightRequests.
+                    for (Iterator<KeyboardFocusManager.LightweightFocusRequest> lwIter = hwFocusRequest.lightweightRequests.
                              iterator();
                          lwIter.hasNext(); )
                     {
                         manager.dequeueKeyEvents
-                            (-1, ((LightweightFocusRequest)lwIter.next()).
+                            (-1, lwIter.next().
                              component);
                     }
                 }
@@ -3063,8 +3063,8 @@
     // Accessor to private field isProxyActive of KeyEvent
     private static boolean isProxyActiveImpl(KeyEvent e) {
         if (proxyActive == null) {
-            proxyActive = (Field) AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+            proxyActive =  AccessController.doPrivileged(new PrivilegedAction<Field>() {
+                    public Field run() {
                         Field field = null;
                         try {
                             field = KeyEvent.class.getDeclaredField("isProxyActive");
--- a/jdk/src/share/classes/java/awt/SequencedEvent.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/SequencedEvent.java	Mon Sep 02 16:48:51 2013 +0400
@@ -49,7 +49,7 @@
 
     private static final int ID =
         java.awt.event.FocusEvent.FOCUS_LAST + 1;
-    private static final LinkedList list = new LinkedList();
+    private static final LinkedList<SequencedEvent> list = new LinkedList<>();
 
     private final AWTEvent nested;
     private AppContext appContext;
--- a/jdk/src/share/classes/java/awt/TexturePaintContext.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/TexturePaintContext.java	Mon Sep 02 16:48:51 2013 +0400
@@ -73,11 +73,11 @@
         WritableRaster raster = bufImg.getRaster();
         ColorModel cm = bufImg.getColorModel();
         int maxw = devBounds.width;
-        Object val = hints.get(hints.KEY_INTERPOLATION);
+        Object val = hints.get(RenderingHints.KEY_INTERPOLATION);
         boolean filter =
             (val == null
-             ? (hints.get(hints.KEY_RENDERING) == hints.VALUE_RENDER_QUALITY)
-             : (val != hints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR));
+             ? (hints.get(RenderingHints.KEY_RENDERING) == RenderingHints.VALUE_RENDER_QUALITY)
+             : (val != RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR));
         if (raster instanceof IntegerInterleavedRaster &&
             (!filter || isFilterableDCM(cm)))
         {
@@ -234,8 +234,8 @@
         return outRas;
     }
 
-    private static WeakReference xrgbRasRef;
-    private static WeakReference argbRasRef;
+    private static WeakReference<Raster> xrgbRasRef;
+    private static WeakReference<Raster> argbRasRef;
 
     synchronized static WritableRaster makeRaster(ColorModel cm,
                                                   Raster srcRas,
@@ -278,13 +278,13 @@
             return;
         }
         if (xrgbmodel == cm) {
-            xrgbRasRef = new WeakReference(outRas);
+            xrgbRasRef = new WeakReference<>(outRas);
         } else if (argbmodel == cm) {
-            argbRasRef = new WeakReference(outRas);
+            argbRasRef = new WeakReference<>(outRas);
         }
     }
 
-    private static WeakReference byteRasRef;
+    private static WeakReference<Raster> byteRasRef;
 
     synchronized static WritableRaster makeByteRaster(Raster srcRas,
                                                       int w, int h)
@@ -307,7 +307,7 @@
         if (outRas == null) {
             return;
         }
-        byteRasRef = new WeakReference(outRas);
+        byteRasRef = new WeakReference<>(outRas);
     }
 
     public abstract WritableRaster makeRaster(int w, int h);
--- a/jdk/src/share/classes/java/awt/WaitDispatchSupport.java	Mon Sep 02 14:06:24 2013 +0400
+++ b/jdk/src/share/classes/java/awt/WaitDispatchSupport.java	Mon Sep 02 16:48:51 2013 +0400
@@ -224,8 +224,8 @@
             // starts. Thus, the enter() method will not hang.
             //
             // Event pump should be privileged. See 6300270.
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
                     run.run();
                     return null;
                 }