7117465: Warning cleanup for IMF classes
authornaoto
Fri, 02 Dec 2011 16:04:16 -0800
changeset 11126 00a6b63e7ba4
parent 11125 99b115114fa3
child 11127 6d29e4d16530
7117465: Warning cleanup for IMF classes Reviewed-by: okutsu
jdk/src/share/classes/java/awt/im/InputMethodHighlight.java
jdk/src/share/classes/sun/awt/im/CompositionArea.java
jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java
jdk/src/share/classes/sun/awt/im/InputContext.java
jdk/src/share/classes/sun/awt/im/InputMethodContext.java
jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java
jdk/src/share/classes/sun/awt/im/InputMethodManager.java
jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java
--- a/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java	Fri Dec 02 17:37:30 2011 +0000
+++ b/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java	Fri Dec 02 16:04:16 2011 -0800
@@ -190,6 +190,6 @@
     private boolean selected;
     private int state;
     private int variation;
-    private Map style;
+    private Map<TextAttribute, ?> style;
 
 };
--- a/jdk/src/share/classes/sun/awt/im/CompositionArea.java	Fri Dec 02 17:37:30 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/im/CompositionArea.java	Fri Dec 02 16:04:16 2011 -0800
@@ -313,4 +313,7 @@
           compositionWindow.pack();
     }
 
+    // Proclaim serial compatibility with 1.7.0
+    private static final long serialVersionUID = -1057247068746557444L;
+
 }
--- a/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java	Fri Dec 02 17:37:30 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java	Fri Dec 02 16:04:16 2011 -0800
@@ -257,7 +257,7 @@
      */
     InputMethodRequests getClientInputMethodRequests() {
         if (clientComponent != null) {
-            return (InputMethodRequests) clientComponent.getInputMethodRequests();
+            return clientComponent.getInputMethodRequests();
         }
 
         return null;
--- a/jdk/src/share/classes/sun/awt/im/InputContext.java	Fri Dec 02 17:37:30 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/im/InputContext.java	Fri Dec 02 16:04:16 2011 -0800
@@ -79,7 +79,7 @@
     private boolean inputMethodCreationFailed;
 
     // holding bin for previously used input method instances, but not the current one
-    private HashMap usedInputMethods;
+    private HashMap<InputMethodLocator, InputMethod> usedInputMethods;
 
     // the current client component is kept until the user focusses on a different
     // client component served by the same input context. When that happens, we call
@@ -106,7 +106,7 @@
     // cache location notification
     private Rectangle clientWindowLocation = null;
     // holding the state of clientWindowNotificationEnabled of only non-current input methods
-    private HashMap perInputMethodState;
+    private HashMap<InputMethod, Boolean> perInputMethodState;
 
     // Input Method selection hot key stuff
     private static AWTKeyStroke inputMethodSelectionKey;
@@ -219,6 +219,7 @@
     /**
      * @see java.awt.im.InputContext#dispatchEvent
      */
+    @SuppressWarnings("fallthrough")
     public void dispatchEvent(AWTEvent event) {
 
         if (event instanceof InputMethodEvent) {
@@ -394,7 +395,7 @@
             isInputMethodActive = true;
 
             if (perInputMethodState != null) {
-                Boolean state = (Boolean) perInputMethodState.remove(inputMethod);
+                Boolean state = perInputMethodState.remove(inputMethod);
                 if (state != null) {
                     clientWindowNotificationEnabled = state.booleanValue();
                 }
@@ -549,10 +550,10 @@
 
             // keep the input method instance around for future use
             if (usedInputMethods == null) {
-                usedInputMethods = new HashMap(5);
+                usedInputMethods = new HashMap<>(5);
             }
             if (perInputMethodState == null) {
-                perInputMethodState = new HashMap(5);
+                perInputMethodState = new HashMap<>(5);
             }
             usedInputMethods.put(inputMethodLocator.deriveLocator(null), inputMethod);
             perInputMethodState.put(inputMethod,
@@ -689,10 +690,10 @@
         }
         inputMethodLocator = null;
         if (usedInputMethods != null && !usedInputMethods.isEmpty()) {
-            Iterator iterator = usedInputMethods.values().iterator();
+            Iterator<InputMethod> iterator = usedInputMethods.values().iterator();
             usedInputMethods = null;
             while (iterator.hasNext()) {
-                ((InputMethod) iterator.next()).dispose();
+                iterator.next().dispose();
             }
         }
 
@@ -830,13 +831,13 @@
 
         // see whether we have a previously used input method
         if (usedInputMethods != null) {
-            inputMethodInstance = (InputMethod) usedInputMethods.remove(locator.deriveLocator(null));
+            inputMethodInstance = usedInputMethods.remove(locator.deriveLocator(null));
             if (inputMethodInstance != null) {
                 if (locale != null) {
                     inputMethodInstance.setLocale(locale);
                 }
                 inputMethodInstance.setCharacterSubsets(characterSubsets);
-                Boolean state = (Boolean) perInputMethodState.remove(inputMethodInstance);
+                Boolean state = perInputMethodState.remove(inputMethodInstance);
                 if (state != null) {
                     enableClientWindowNotification(inputMethodInstance, state.booleanValue());
                 }
@@ -919,7 +920,7 @@
         // method becomes the current one.
         if (requester != inputMethod) {
             if (perInputMethodState == null) {
-                perInputMethodState = new HashMap(5);
+                perInputMethodState = new HashMap<>(5);
             }
             perInputMethodState.put(requester, Boolean.valueOf(enable));
             return;
@@ -1029,7 +1030,7 @@
      * Initializes the input method selection key definition in preference trees
      */
     private void initializeInputMethodSelectionKey() {
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
             public Object run() {
                 // Look in user's tree
                 Preferences root = Preferences.userRoot();
--- a/jdk/src/share/classes/sun/awt/im/InputMethodContext.java	Fri Dec 02 17:37:30 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodContext.java	Fri Dec 02 16:04:16 2011 -0800
@@ -72,12 +72,11 @@
     static {
         // check whether we should use below-the-spot input
         // get property from command line
-        String inputStyle = (String) AccessController.doPrivileged
+        String inputStyle = AccessController.doPrivileged
                 (new GetPropertyAction("java.awt.im.style", null));
         // get property from awt.properties file
         if (inputStyle == null) {
-            inputStyle = Toolkit.getDefaultToolkit().
-                    getProperty("java.awt.im.style", null);
+            inputStyle = Toolkit.getProperty("java.awt.im.style", null);
         }
         belowTheSpotInputRequested = "below-the-spot".equals(inputStyle);
     }
--- a/jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java	Fri Dec 02 17:37:30 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java	Fri Dec 02 16:04:16 2011 -0800
@@ -68,4 +68,7 @@
             return super.getInputContext();
         }
     }
+
+    // Proclaim serial compatibility with 1.7.0
+    private static final long serialVersionUID = -4705856747771842549L;
 }
--- a/jdk/src/share/classes/sun/awt/im/InputMethodManager.java	Fri Dec 02 17:37:30 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodManager.java	Fri Dec 02 16:04:16 2011 -0800
@@ -270,7 +270,7 @@
     // IM preference stuff
     private static final String preferredIMNode = "/sun/awt/im/preferredInputMethod";
     private static final String descriptorKey = "descriptor";
-    private Hashtable preferredLocatorCache = new Hashtable();
+    private Hashtable<String, InputMethodLocator> preferredLocatorCache = new Hashtable<>();
     private Preferences userRoot;
 
     ExecutableInputMethodManager() {
@@ -430,7 +430,7 @@
         synchronized (javaInputMethodLocatorList) {
             javaInputMethodLocatorList.clear();
             try {
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                     public Object run() {
                         for (InputMethodDescriptor descriptor :
                             ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
@@ -611,7 +611,7 @@
         }
 
         // look for the cached preference first.
-        preferredLocator = (InputMethodLocator)preferredLocatorCache.get(locale.toString().intern());
+        preferredLocator = preferredLocatorCache.get(locale.toString().intern());
         if (preferredLocator != null) {
             return preferredLocator;
         }
@@ -767,8 +767,8 @@
     }
 
     private Preferences getUserRoot() {
-        return (Preferences)AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        return AccessController.doPrivileged(new PrivilegedAction<Preferences>() {
+            public Preferences run() {
                 return Preferences.userRoot();
             }
         });
--- a/jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java	Fri Dec 02 17:37:30 2011 +0000
+++ b/jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java	Fri Dec 02 16:04:16 2011 -0800
@@ -61,4 +61,7 @@
             return super.getInputContext();
         }
     }
+
+    // Proclaim serial compatibility with 1.7.0
+    private static final long serialVersionUID = 5093376647036461555L;
 }