src/share/classes/java/awt/AWTKeyStroke.java

Print this page

        

@@ -65,11 +65,11 @@
  * @since 1.4
  */
 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
      * constant.
      */

@@ -83,12 +83,12 @@
     /*
      * Reads keystroke class from AppContext and if null, puts there the
      * 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);
         }
         return clazz;

@@ -180,11 +180,11 @@
     protected static void registerSubclass(Class<?> subclass) {
         if (subclass == null) {
             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;
             }
         }

@@ -227,12 +227,12 @@
        threat as accessible flag is set only for this Constructor object,
        not for Class constructor.
      */
     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) {
                         ctor.setAccessible(true);
                     }

@@ -247,21 +247,21 @@
     }
 
     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) {
                 assert(false);
             } catch (IllegalAccessException e) {

@@ -511,11 +511,11 @@
         boolean typed = false;
         boolean pressed = false;
 
         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));
                 uninitializedMap.put("control",
                                      Integer.valueOf(InputEvent.CTRL_DOWN_MASK

@@ -859,16 +859,16 @@
     }
 
 }
 
 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) {
         assert((name != null) && (code != null));
         assert(findName(code) == null);