7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package
authorbagiras
Mon, 19 Dec 2011 15:21:35 +0400
changeset 11270 d7b0b63bd082
parent 11269 138525605d98
child 11271 f10f98b24801
7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package Reviewed-by: art, denis, alexsch
jdk/src/share/classes/java/awt/AWTEvent.java
jdk/src/share/classes/java/awt/AWTEventMulticaster.java
jdk/src/share/classes/java/awt/Component.java
jdk/src/share/classes/java/awt/Font.java
jdk/src/share/classes/java/awt/Toolkit.java
jdk/src/share/classes/java/awt/image/ColorModel.java
--- a/jdk/src/share/classes/java/awt/AWTEvent.java	Fri Dec 16 12:12:17 2011 -0800
+++ b/jdk/src/share/classes/java/awt/AWTEvent.java	Mon Dec 19 15:21:35 2011 +0400
@@ -278,9 +278,9 @@
     private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
         if (inputEvent_CanAccessSystemClipboard_Field == null) {
             inputEvent_CanAccessSystemClipboard_Field =
-                (Field)java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction() {
-                            public Object run() {
+                java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedAction<Field>() {
+                            public Field run() {
                                 Field field = null;
                                 try {
                                     field = InputEvent.class.
--- a/jdk/src/share/classes/java/awt/AWTEventMulticaster.java	Fri Dec 16 12:12:17 2011 -0800
+++ b/jdk/src/share/classes/java/awt/AWTEventMulticaster.java	Mon Dec 19 15:21:35 2011 +0400
@@ -953,7 +953,7 @@
      * AWTEventMulticaster.  Additionally, only listeners of type listenerType
      * are counted.  Method modified to fix bug 4513402.  -bchristi
      */
-    private static int getListenerCount(EventListener l, Class listenerType) {
+    private static int getListenerCount(EventListener l, Class<?> listenerType) {
         if (l instanceof AWTEventMulticaster) {
             AWTEventMulticaster mc = (AWTEventMulticaster)l;
             return getListenerCount(mc.a, listenerType) +
@@ -1017,6 +1017,7 @@
      *
      * @since 1.4
      */
+    @SuppressWarnings("unchecked")
     public static <T extends EventListener> T[]
         getListeners(EventListener l, Class<T> listenerType)
     {
--- a/jdk/src/share/classes/java/awt/Component.java	Fri Dec 16 12:12:17 2011 -0800
+++ b/jdk/src/share/classes/java/awt/Component.java	Mon Dec 19 15:21:35 2011 +0400
@@ -382,7 +382,7 @@
      * @serial
      * @see #add
      */
-    Vector popups;
+    Vector<PopupMenu> popups;
 
     /**
      * A component's name.
@@ -441,7 +441,7 @@
      * @see #getFocusTraversalKeys
      * @since 1.4
      */
-    Set[] focusTraversalKeys;
+    Set<AWTKeyStroke>[] focusTraversalKeys;
 
     private static final String[] focusTraversalKeyPropertyNames = {
         "forwardFocusTraversalKeys",
@@ -598,12 +598,12 @@
             initIDs();
         }
 
-        String s = (String) java.security.AccessController.doPrivileged(
-                                                                        new GetPropertyAction("awt.image.incrementaldraw"));
+        String s = java.security.AccessController.doPrivileged(
+                                                               new GetPropertyAction("awt.image.incrementaldraw"));
         isInc = (s == null || s.equals("true"));
 
-        s = (String) java.security.AccessController.doPrivileged(
-                                                                 new GetPropertyAction("awt.image.redrawrate"));
+        s = java.security.AccessController.doPrivileged(
+                                                        new GetPropertyAction("awt.image.redrawrate"));
         incRate = (s != null) ? Integer.parseInt(s) : 100;
     }
 
@@ -986,6 +986,7 @@
         appContext = AppContext.getAppContext();
     }
 
+    @SuppressWarnings({"rawtypes", "unchecked"})
     void initializeFocusTraversalKeys() {
         focusTraversalKeys = new Set[3];
     }
@@ -1369,13 +1370,13 @@
             throw new HeadlessException();
         }
 
-        PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged(
-                                                                                  new java.security.PrivilegedAction() {
-                                                                                      public Object run() {
-                                                                                          return MouseInfo.getPointerInfo();
-                                                                                      }
-                                                                                  }
-                                                                                  );
+        PointerInfo pi = java.security.AccessController.doPrivileged(
+                                                                     new java.security.PrivilegedAction<PointerInfo>() {
+                                                                         public PointerInfo run() {
+                                                                             return MouseInfo.getPointerInfo();
+                                                                         }
+                                                                     }
+                                                                     );
 
         synchronized (getTreeLock()) {
             Component inTheSameWindow = findUnderMouseInWindow(pi);
@@ -2334,7 +2335,7 @@
         peer.setBounds(nativeX, nativeY, width, height, op);
     }
 
-
+    @SuppressWarnings("deprecation")
     private void notifyNewBounds(boolean resized, boolean moved) {
         if (componentListener != null
             || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0
@@ -4690,6 +4691,7 @@
         dispatchEventImpl(e);
     }
 
+    @SuppressWarnings("deprecation")
     void dispatchEventImpl(AWTEvent e) {
         int id = e.getID();
 
@@ -5242,7 +5244,7 @@
      * @since 1.4
      */
     public synchronized ComponentListener[] getComponentListeners() {
-        return (ComponentListener[]) (getListeners(ComponentListener.class));
+        return getListeners(ComponentListener.class);
     }
 
     /**
@@ -5311,7 +5313,7 @@
      * @since 1.4
      */
     public synchronized FocusListener[] getFocusListeners() {
-        return (FocusListener[]) (getListeners(FocusListener.class));
+        return getListeners(FocusListener.class);
     }
 
     /**
@@ -5402,7 +5404,7 @@
      * @since    1.4
      */
     public synchronized HierarchyListener[] getHierarchyListeners() {
-        return (HierarchyListener[])(getListeners(HierarchyListener.class));
+        return getListeners(HierarchyListener.class);
     }
 
     /**
@@ -5564,8 +5566,7 @@
      * @since    1.4
      */
     public synchronized HierarchyBoundsListener[] getHierarchyBoundsListeners() {
-        return (HierarchyBoundsListener[])
-            (getListeners(HierarchyBoundsListener.class));
+        return getListeners(HierarchyBoundsListener.class);
     }
 
     /*
@@ -5644,7 +5645,7 @@
      * @since    1.4
      */
     public synchronized KeyListener[] getKeyListeners() {
-        return (KeyListener[]) (getListeners(KeyListener.class));
+        return getListeners(KeyListener.class);
     }
 
     /**
@@ -5713,7 +5714,7 @@
      * @since    1.4
      */
     public synchronized MouseListener[] getMouseListeners() {
-        return (MouseListener[]) (getListeners(MouseListener.class));
+        return getListeners(MouseListener.class);
     }
 
     /**
@@ -5782,7 +5783,7 @@
      * @since    1.4
      */
     public synchronized MouseMotionListener[] getMouseMotionListeners() {
-        return (MouseMotionListener[]) (getListeners(MouseMotionListener.class));
+        return getListeners(MouseMotionListener.class);
     }
 
     /**
@@ -5855,7 +5856,7 @@
      * @since    1.4
      */
     public synchronized MouseWheelListener[] getMouseWheelListeners() {
-        return (MouseWheelListener[]) (getListeners(MouseWheelListener.class));
+        return getListeners(MouseWheelListener.class);
     }
 
     /**
@@ -5922,7 +5923,7 @@
      * @since    1.4
      */
     public synchronized InputMethodListener[] getInputMethodListeners() {
-        return (InputMethodListener[]) (getListeners(InputMethodListener.class));
+        return getListeners(InputMethodListener.class);
     }
 
     /**
@@ -5967,6 +5968,7 @@
      *
      * @since 1.3
      */
+    @SuppressWarnings("unchecked")
     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
         EventListener l = null;
         if  (listenerType == ComponentListener.class) {
@@ -6909,7 +6911,7 @@
 
             int npopups = (popups != null? popups.size() : 0);
             for (int i = 0 ; i < npopups ; i++) {
-                PopupMenu popup = (PopupMenu)popups.elementAt(i);
+                PopupMenu popup = popups.elementAt(i);
                 popup.addNotify();
             }
 
@@ -6979,7 +6981,7 @@
 
             int npopups = (popups != null? popups.size() : 0);
             for (int i = 0 ; i < npopups ; i++) {
-                PopupMenu popup = (PopupMenu)popups.elementAt(i);
+                PopupMenu popup = popups.elementAt(i);
                 popup.removeNotify();
             }
             // If there is any input context for this component, notify
@@ -7238,7 +7240,7 @@
     // would erroneously generate an IllegalArgumentException for
     // DOWN_CYCLE_TRAVERSAL_KEY.
     final void setFocusTraversalKeys_NoIDCheck(int id, Set<? extends AWTKeyStroke> keystrokes) {
-        Set oldKeys;
+        Set<AWTKeyStroke> oldKeys;
 
         synchronized (this) {
             if (focusTraversalKeys == null) {
@@ -7246,20 +7248,12 @@
             }
 
             if (keystrokes != null) {
-                for (Iterator iter = keystrokes.iterator(); iter.hasNext(); ) {
-                    Object obj = iter.next();
-
-                    if (obj == null) {
+                for (AWTKeyStroke keystroke : keystrokes ) {
+
+                    if (keystroke == null) {
                         throw new IllegalArgumentException("cannot set null focus traversal key");
                     }
 
-                    // Fix for 6195828:
-                    //According to javadoc this method should throw IAE instead of ClassCastException
-                    if (!(obj instanceof AWTKeyStroke)) {
-                        throw new IllegalArgumentException("object is expected to be AWTKeyStroke");
-                    }
-                    AWTKeyStroke keystroke = (AWTKeyStroke)obj;
-
                     if (keystroke.getKeyChar() != KeyEvent.CHAR_UNDEFINED) {
                         throw new IllegalArgumentException("focus traversal keys cannot map to KEY_TYPED events");
                     }
@@ -7279,16 +7273,16 @@
 
             oldKeys = focusTraversalKeys[id];
             focusTraversalKeys[id] = (keystrokes != null)
-                ? Collections.unmodifiableSet(new HashSet(keystrokes))
+                ? Collections.unmodifiableSet(new HashSet<AWTKeyStroke>(keystrokes))
                 : null;
         }
 
         firePropertyChange(focusTraversalKeyPropertyNames[id], oldKeys,
                            keystrokes);
     }
-    final Set getFocusTraversalKeys_NoIDCheck(int id) {
+    final Set<AWTKeyStroke> getFocusTraversalKeys_NoIDCheck(int id) {
         // Okay to return Set directly because it is an unmodifiable view
-        Set keystrokes = (focusTraversalKeys != null)
+        Set<AWTKeyStroke> keystrokes = (focusTraversalKeys != null)
             ? focusTraversalKeys[id]
             : null;
 
@@ -7686,7 +7680,7 @@
         }
 
         Window window = getContainingWindow();
-        if (window == null || !((Window)window).isFocusableWindow()) {
+        if (window == null || !window.isFocusableWindow()) {
             if (focusLog.isLoggable(PlatformLogger.FINEST)) {
                 focusLog.finest("Component doesn't have toplevel");
             }
@@ -8025,7 +8019,7 @@
                 popup.parent.remove(popup);
             }
             if (popups == null) {
-                popups = new Vector();
+                popups = new Vector<PopupMenu>();
             }
             popups.addElement(popup);
             popup.parent = this;
@@ -8044,6 +8038,7 @@
      * @see       #add(PopupMenu)
      * @since     JDK1.1
      */
+    @SuppressWarnings("unchecked")
     public void remove(MenuComponent popup) {
         synchronized (getTreeLock()) {
             if (popups == null) {
@@ -8556,26 +8551,26 @@
         //
         // Swing classes MUST be loaded by the bootstrap class loader,
         // otherwise we don't consider them.
-        for (Class klass = Component.this.getClass(); klass != null;
+        for (Class<?> klass = Component.this.getClass(); klass != null;
                    klass = klass.getSuperclass()) {
             if (klass.getPackage() == swingPackage &&
                       klass.getClassLoader() == null) {
-                final Class swingClass = klass;
+                final Class<?> swingClass = klass;
                 // Find the first override of the compWriteObjectNotify method
-                Method[] methods = (Method[])AccessController.doPrivileged(
-                                                                           new PrivilegedAction() {
-                                                                               public Object run() {
-                                                                                   return swingClass.getDeclaredMethods();
-                                                                               }
-                                                                           });
+                Method[] methods = AccessController.doPrivileged(
+                                                                 new PrivilegedAction<Method[]>() {
+                                                                     public Method[] run() {
+                                                                         return swingClass.getDeclaredMethods();
+                                                                     }
+                                                                 });
                 for (int counter = methods.length - 1; counter >= 0;
                      counter--) {
                     final Method method = methods[counter];
                     if (method.getName().equals("compWriteObjectNotify")){
                         // We found it, use doPrivileged to make it accessible
                         // to use.
-                        AccessController.doPrivileged(new PrivilegedAction() {
-                                public Object run() {
+                        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                                public Void run() {
                                     method.setAccessible(true);
                                     return null;
                                 }
@@ -8804,7 +8799,7 @@
         if (popups != null) {
             int npopups = popups.size();
             for (int i = 0 ; i < npopups ; i++) {
-                PopupMenu popup = (PopupMenu)popups.elementAt(i);
+                PopupMenu popup = popups.elementAt(i);
                 popup.parent = this;
             }
         }
@@ -9658,7 +9653,7 @@
         if (obj == null) return false;
         if (className == null) return false;
 
-        Class cls = obj.getClass();
+        Class<?> cls = obj.getClass();
         while (cls != null) {
             if (cls.getName().equals(className)) {
                 return true;
--- a/jdk/src/share/classes/java/awt/Font.java	Fri Dec 16 12:12:17 2011 -0800
+++ b/jdk/src/share/classes/java/awt/Font.java	Mon Dec 19 15:21:35 2011 +0400
@@ -254,7 +254,7 @@
      * @serial
      * @see #getAttributes()
      */
-    private Hashtable fRequestedAttributes;
+    private Hashtable<Object, Object> fRequestedAttributes;
 
     /*
      * Constants to be used for logical font family names.
@@ -446,6 +446,7 @@
     //       We implement this functionality in a package-private method
     //       to insure that it cannot be overridden by client subclasses.
     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
+    @SuppressWarnings("deprecation")
     final FontPeer getPeer_NoClientCode() {
         if(peer == null) {
             Toolkit tk = Toolkit.getDefaultToolkit();
@@ -907,11 +908,11 @@
                             break;
                         }
                         if (tracker != null) {
-                            if (totalSize+bytesRead > tracker.MAX_FILE_SIZE) {
+                            if (totalSize+bytesRead > CreatedFontTracker.MAX_FILE_SIZE) {
                                 throw new IOException("File too big.");
                             }
                             if (totalSize+tracker.getNumBytes() >
-                                tracker.MAX_TOTAL_BYTES)
+                                CreatedFontTracker.MAX_TOTAL_BYTES)
                               {
                                 throw new IOException("Total files too big.");
                             }
@@ -2126,11 +2127,11 @@
         return false;   // REMIND always safe, but prevents caller optimize
     }
 
-    private transient SoftReference flmref;
+    private transient SoftReference<FontLineMetrics> flmref;
     private FontLineMetrics defaultLineMetrics(FontRenderContext frc) {
         FontLineMetrics flm = null;
         if (flmref == null
-            || (flm = (FontLineMetrics)flmref.get()) == null
+            || (flm = flmref.get()) == null
             || !flm.frc.equals(frc)) {
 
             /* The device transform in the frc is not used in obtaining line
@@ -2194,7 +2195,7 @@
                                              ssOffset, italicAngle);
 
             flm = new FontLineMetrics(0, cm, frc);
-            flmref = new SoftReference(flm);
+            flmref = new SoftReference<FontLineMetrics>(flm);
         }
 
         return (FontLineMetrics)flm.clone();
--- a/jdk/src/share/classes/java/awt/Toolkit.java	Fri Dec 16 12:12:17 2011 -0800
+++ b/jdk/src/share/classes/java/awt/Toolkit.java	Mon Dec 19 15:21:35 2011 +0400
@@ -706,9 +706,9 @@
         final Properties properties = new Properties();
 
 
-        atNames = (String)java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-            public Object run() {
+        atNames = java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<String>() {
+            public String run() {
 
                 // Try loading the per-user accessibility properties file.
                 try {
@@ -798,7 +798,7 @@
             while (parser.hasMoreTokens()) {
                 atName = parser.nextToken();
                 try {
-                    Class clazz;
+                    Class<?> clazz;
                     if (cl != null) {
                         clazz = cl.loadClass(atName);
                     } else {
@@ -860,8 +860,8 @@
                 java.lang.Compiler.disable();
 
                 java.security.AccessController.doPrivileged(
-                        new java.security.PrivilegedAction() {
-                    public Object run() {
+                        new java.security.PrivilegedAction<Void>() {
+                    public Void run() {
                         String nm = null;
                         Class cls = null;
                         try {
@@ -1653,8 +1653,8 @@
 
     static {
         java.security.AccessController.doPrivileged(
-                                 new java.security.PrivilegedAction() {
-            public Object run() {
+                                 new java.security.PrivilegedAction<Void>() {
+            public Void run() {
                 try {
                     resources =
                         ResourceBundle.getBundle("sun.awt.resources.awt",
@@ -1984,7 +1984,7 @@
     private int[] calls = new int[LONG_BITS];
     private static volatile long enabledOnToolkitMask;
     private AWTEventListener eventListener = null;
-    private WeakHashMap listener2SelectiveListener = new WeakHashMap();
+    private WeakHashMap<AWTEventListener, SelectiveAWTEventListener> listener2SelectiveListener = new WeakHashMap<>();
 
     /*
      * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy,
@@ -2051,7 +2051,7 @@
         }
         synchronized (this) {
             SelectiveAWTEventListener selectiveListener =
-            (SelectiveAWTEventListener)listener2SelectiveListener.get(localL);
+                listener2SelectiveListener.get(localL);
 
             if (selectiveListener == null) {
                 // Create a new selectiveListener.
@@ -2121,7 +2121,7 @@
 
         synchronized (this) {
             SelectiveAWTEventListener selectiveListener =
-            (SelectiveAWTEventListener)listener2SelectiveListener.get(localL);
+                listener2SelectiveListener.get(localL);
 
             if (selectiveListener != null) {
                 listener2SelectiveListener.remove(localL);
@@ -2244,7 +2244,7 @@
         synchronized (this) {
             EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
 
-            java.util.List list = new ArrayList(la.length);
+            java.util.List<AWTEventListenerProxy> list = new ArrayList<>(la.length);
 
             for (int i = 0; i < la.length; i++) {
                 SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];
@@ -2254,7 +2254,7 @@
                                                        sael.getListener()));
                 }
             }
-            return (AWTEventListener[])list.toArray(new AWTEventListener[0]);
+            return list.toArray(new AWTEventListener[0]);
         }
     }
 
@@ -2457,7 +2457,9 @@
         }
     }
 
+    @SuppressWarnings("serial")
     private static class DesktopPropertyChangeSupport extends PropertyChangeSupport {
+
         private static final StringBuilder PROP_CHANGE_SUPPORT_KEY =
                 new StringBuilder("desktop property change support key");
         private final Object source;
--- a/jdk/src/share/classes/java/awt/image/ColorModel.java	Fri Dec 16 12:12:17 2011 -0800
+++ b/jdk/src/share/classes/java/awt/image/ColorModel.java	Mon Dec 19 15:21:35 2011 +0400
@@ -357,7 +357,7 @@
             this.transparency         = transparency;
         }
 
-        nBits = (int[]) bits.clone();
+        nBits = bits.clone();
         this.pixel_bits = pixel_bits;
         if (pixel_bits <= 0) {
             throw new IllegalArgumentException("Number of pixel bits must "+
@@ -474,7 +474,7 @@
      */
     public int[] getComponentSize() {
         if (nBits != null) {
-            return (int[]) nBits.clone();
+            return nBits.clone();
         }
 
         return null;
@@ -1692,10 +1692,10 @@
     static short[] s8Tol16 = null; // 8-bit non-linear sRGB to 16-bit linear LUT
 
                                 // Maps to hold LUTs for grayscale conversions
-    static Map g8Tos8Map = null;     // 8-bit gray values to 8-bit sRGB values
-    static Map lg16Toog8Map = null;  // 16-bit linear to 8-bit "other" gray
-    static Map g16Tos8Map = null;    // 16-bit gray values to 8-bit sRGB values
-    static Map lg16Toog16Map = null; // 16-bit linear to 16-bit "other" gray
+    static Map<ICC_ColorSpace, byte[]> g8Tos8Map = null;     // 8-bit gray values to 8-bit sRGB values
+    static Map<ICC_ColorSpace, byte[]> lg16Toog8Map = null;  // 16-bit linear to 8-bit "other" gray
+    static Map<ICC_ColorSpace, byte[]> g16Tos8Map = null;    // 16-bit gray values to 8-bit sRGB values
+    static Map<ICC_ColorSpace, short[]> lg16Toog16Map = null; // 16-bit linear to 16-bit "other" gray
 
     static boolean isLinearRGBspace(ColorSpace cs) {
         // Note: CMM.LINEAR_RGBspace will be null if the linear
@@ -1799,7 +1799,7 @@
             return getLinearRGB8TosRGB8LUT();
         }
         if (g8Tos8Map != null) {
-            byte[] g8Tos8LUT = (byte []) g8Tos8Map.get(grayCS);
+            byte[] g8Tos8LUT = g8Tos8Map.get(grayCS);
             if (g8Tos8LUT != null) {
                 return g8Tos8LUT;
             }
@@ -1827,7 +1827,7 @@
             g8Tos8LUT[i] = tmp[j];
         }
         if (g8Tos8Map == null) {
-            g8Tos8Map = Collections.synchronizedMap(new WeakHashMap(2));
+            g8Tos8Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, byte[]>(2));
         }
         g8Tos8Map.put(grayCS, g8Tos8LUT);
         return g8Tos8LUT;
@@ -1840,7 +1840,7 @@
      */
     static byte[] getLinearGray16ToOtherGray8LUT(ICC_ColorSpace grayCS) {
         if (lg16Toog8Map != null) {
-            byte[] lg16Toog8LUT = (byte []) lg16Toog8Map.get(grayCS);
+            byte[] lg16Toog8LUT = lg16Toog8Map.get(grayCS);
             if (lg16Toog8LUT != null) {
                 return lg16Toog8LUT;
             }
@@ -1866,7 +1866,7 @@
                 (byte) (((float) (tmp[i] & 0xffff)) * (1.0f /257.0f) + 0.5f);
         }
         if (lg16Toog8Map == null) {
-            lg16Toog8Map = Collections.synchronizedMap(new WeakHashMap(2));
+            lg16Toog8Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, byte[]>(2));
         }
         lg16Toog8Map.put(grayCS, lg16Toog8LUT);
         return lg16Toog8LUT;
@@ -1884,7 +1884,7 @@
             return getLinearRGB16TosRGB8LUT();
         }
         if (g16Tos8Map != null) {
-            byte[] g16Tos8LUT = (byte []) g16Tos8Map.get(grayCS);
+            byte[] g16Tos8LUT = g16Tos8Map.get(grayCS);
             if (g16Tos8LUT != null) {
                 return g16Tos8LUT;
             }
@@ -1916,7 +1916,7 @@
                 (byte) (((float) (tmp[j] & 0xffff)) * (1.0f /257.0f) + 0.5f);
         }
         if (g16Tos8Map == null) {
-            g16Tos8Map = Collections.synchronizedMap(new WeakHashMap(2));
+            g16Tos8Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, byte[]>(2));
         }
         g16Tos8Map.put(grayCS, g16Tos8LUT);
         return g16Tos8LUT;
@@ -1929,7 +1929,7 @@
      */
     static short[] getLinearGray16ToOtherGray16LUT(ICC_ColorSpace grayCS) {
         if (lg16Toog16Map != null) {
-            short[] lg16Toog16LUT = (short []) lg16Toog16Map.get(grayCS);
+            short[] lg16Toog16LUT = lg16Toog16Map.get(grayCS);
             if (lg16Toog16LUT != null) {
                 return lg16Toog16LUT;
             }
@@ -1950,7 +1950,7 @@
             transformList);
         short[] lg16Toog16LUT = t.colorConvert(tmp, null);
         if (lg16Toog16Map == null) {
-            lg16Toog16Map = Collections.synchronizedMap(new WeakHashMap(2));
+            lg16Toog16Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, short[]>(2));
         }
         lg16Toog16Map.put(grayCS, lg16Toog16LUT);
         return lg16Toog16LUT;