src/share/classes/java/awt/KeyboardFocusManager.java

Print this page

        

@@ -346,10 +346,11 @@
      * in effect on all Windows that have no such array of their own explicitly
      * set. Each array will also be inherited, recursively, by any child
      * Component of those Windows that has no such array of its own explicitly
      * set.
      */
+    @SuppressWarnings({"unchecked", "rawtypes"})
     private Set<AWTKeyStroke>[] defaultFocusTraversalKeys = new Set[4];
 
     /**
      * The current focus cycle root. If the focus owner is itself a focus cycle
      * root, then it may be ambiguous as to which Components represent the next

@@ -420,11 +421,11 @@
         StringTokenizer tokens = new StringTokenizer(value, ",");
         while (tokens.hasMoreTokens()) {
             targetSet.add(AWTKeyStroke.getAWTKeyStroke(tokens.nextToken()));
         }
         return (targetSet.isEmpty())
-            ? Collections.EMPTY_SET
+            ? Collections.emptySet()
             : Collections.unmodifiableSet(targetSet);
     }
 
     /**
      * Initializes a KeyboardFocusManager.

@@ -434,11 +435,11 @@
             Set<AWTKeyStroke> work_set = new HashSet<>();
             for (int j = 0; j < defaultFocusTraversalKeyStrokes[i].length; j++) {
                 work_set.add(defaultFocusTraversalKeyStrokes[i][j]);
             }
             defaultFocusTraversalKeys[i] = (work_set.isEmpty())
-                ? Collections.EMPTY_SET
+                ? Collections.emptySet()
                 : Collections.unmodifiableSet(work_set);
         }
         initPeer();
     }
 

@@ -1748,15 +1749,16 @@
      *
      * @return a possibly null or empty List of KeyEventDispatchers
      * @see #addKeyEventDispatcher
      * @see #removeKeyEventDispatcher
      */
+    @SuppressWarnings("unchecked") // Cast of result of clone
     protected synchronized java.util.List<KeyEventDispatcher>
         getKeyEventDispatchers()
     {
         return (keyEventDispatchers != null)
-            ? (java.util.List)keyEventDispatchers.clone()
+            ? (java.util.List<KeyEventDispatcher>)keyEventDispatchers.clone()
             : null;
     }
 
     /**
      * Adds a KeyEventPostProcessor to this KeyboardFocusManager's post-

@@ -1839,15 +1841,16 @@
      *
      * @return a possibly null or empty List of KeyEventPostProcessors
      * @see #addKeyEventPostProcessor
      * @see #removeKeyEventPostProcessor
      */
+    @SuppressWarnings("unchecked") // Cast of result of clone
     protected java.util.List<KeyEventPostProcessor>
         getKeyEventPostProcessors()
     {
         return (keyEventPostProcessors != null)
-            ? (java.util.List)keyEventPostProcessors.clone()
+            ? (java.util.List<KeyEventPostProcessor>)keyEventPostProcessors.clone()
             : null;
     }
 
 
 

@@ -1905,12 +1908,11 @@
     /*
      * Please be careful changing this method! It is called from
      * javax.swing.JComponent.runInputVerifier() using reflection.
      */
     static synchronized Component getMostRecentFocusOwner(Window window) {
-        WeakReference<Component> weakValue =
-            (WeakReference)mostRecentFocusOwners.get(window);
+        WeakReference<Component> weakValue = mostRecentFocusOwners.get(window);
         return weakValue == null ? null : weakValue.get();
     }
 
     /**
      * This method is called by the AWT event dispatcher requesting that the