8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
authorhenryjen
Thu, 05 Jun 2014 13:59:01 -0700
changeset 25192 4e2dc0f8702d
parent 25191 a41ac4e87fc4
child 25193 187a455af8f8
8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files 8044396: Fix raw and unchecked lint warnings in platform-specific sun.java2d.* Reviewed-by: darcy, prr
jdk/src/windows/classes/sun/awt/Win32FontManager.java
jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java
jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java
jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java
jdk/src/windows/classes/sun/awt/windows/WDragSourceContextPeer.java
jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java
jdk/src/windows/classes/sun/awt/windows/WFontMetrics.java
jdk/src/windows/classes/sun/awt/windows/WInputMethod.java
jdk/src/windows/classes/sun/awt/windows/WToolkit.java
jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java
jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java
jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java
jdk/src/windows/classes/sun/java2d/windows/WindowsFlags.java
--- a/jdk/src/windows/classes/sun/awt/Win32FontManager.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/Win32FontManager.java	Thu Jun 05 13:59:01 2014 -0700
@@ -42,8 +42,6 @@
 import sun.font.FontManager;
 import sun.font.SunFontManager;
 import sun.font.TrueTypeFont;
-import sun.java2d.HeadlessGraphicsEnvironment;
-import sun.java2d.SunGraphicsEnvironment;
 
 /**
  * The X11 implementation of {@link FontManager}.
@@ -56,7 +54,7 @@
 
     static {
 
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
 
                 public Object run() {
                     String eudcFile = getEUDCFontFile();
@@ -90,7 +88,7 @@
 
     public Win32FontManager() {
         super();
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
 
                     /* Register the JRE fonts so that the native platform can
@@ -227,7 +225,7 @@
         final String[] dirs = getPlatformFontDirs(true);
         if (dirs.length > 1) {
             String dir = (String)
-                AccessController.doPrivileged(new PrivilegedAction() {
+                AccessController.doPrivileged(new PrivilegedAction<Object>() {
                         public Object run() {
                             for (int i=0; i<dirs.length; i++) {
                                 String path =
@@ -272,7 +270,7 @@
             fontsForPrinting = null;
         }
         java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
+            new java.security.PrivilegedAction<Object>() {
                 public Object run() {
                     File f1 = new File(pathName);
                     String[] ls = f1.list(SunFontManager.getInstance().
--- a/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsDevice.java	Thu Jun 05 13:59:01 2014 -0700
@@ -172,7 +172,7 @@
 
             int max = getMaxConfigs(screen);
             int defaultPixID = getDefaultPixID(screen);
-            Vector v = new Vector( max );
+            Vector<GraphicsConfiguration> v = new Vector<>( max );
             if (defaultPixID == 0) {
                 // Workaround for failing GDI calls
                 defaultConfig = Win32GraphicsConfig.getConfig(this,
@@ -437,7 +437,7 @@
     protected native void configDisplayMode(int screen, WindowPeer w, int width,
                                           int height, int bitDepth,
                                           int refreshRate);
-    protected native void enumDisplayModes(int screen, ArrayList modes);
+    protected native void enumDisplayModes(int screen, ArrayList<DisplayMode> modes);
 
     @Override
     public synchronized DisplayMode getDisplayMode() {
@@ -447,12 +447,12 @@
 
     @Override
     public synchronized DisplayMode[] getDisplayModes() {
-        ArrayList modes = new ArrayList();
+        ArrayList<DisplayMode> modes = new ArrayList<>();
         enumDisplayModes(screen, modes);
         int listSize = modes.size();
         DisplayMode[] retArray = new DisplayMode[listSize];
         for (int i = 0; i < listSize; i++) {
-            retArray[i] = (DisplayMode)modes.get(i);
+            retArray[i] = modes.get(i);
         }
         return retArray;
     }
--- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Thu Jun 05 13:59:01 2014 -0700
@@ -894,10 +894,10 @@
 
     // Icons
 
-    private static Map smallSystemImages = new HashMap();
-    private static Map largeSystemImages = new HashMap();
-    private static Map smallLinkedSystemImages = new HashMap();
-    private static Map largeLinkedSystemImages = new HashMap();
+    private static Map<Integer, Image> smallSystemImages = new HashMap<>();
+    private static Map<Integer, Image> largeSystemImages = new HashMap<>();
+    private static Map<Integer, Image> smallLinkedSystemImages = new HashMap<>();
+    private static Map<Integer, Image> largeLinkedSystemImages = new HashMap<>();
 
     // NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
     private static native long getIShellIcon(long pIShellFolder);
@@ -970,13 +970,13 @@
                             // These are cached per type (using the index in the system image list)
                             int index = getIconIndex(parentIShellIcon, relativePIDL);
                             if (index > 0) {
-                                Map imageCache;
+                                Map<Integer, Image> imageCache;
                                 if (isLink()) {
                                     imageCache = getLargeIcon ? largeLinkedSystemImages : smallLinkedSystemImages;
                                 } else {
                                     imageCache = getLargeIcon ? largeSystemImages : smallSystemImages;
                                 }
-                                newIcon = (Image) imageCache.get(Integer.valueOf(index));
+                                newIcon = imageCache.get(Integer.valueOf(index));
                                 if (newIcon == null) {
                                     long hIcon = getIcon(getAbsolutePath(), getLargeIcon);
                                     newIcon = makeIcon(hIcon, getLargeIcon);
--- a/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java	Thu Jun 05 13:59:01 2014 -0700
@@ -414,14 +414,14 @@
         return false;
     }
 
-    private static List topFolderList = null;
+    private static List<Win32ShellFolder2> topFolderList = null;
     static int compareShellFolders(Win32ShellFolder2 sf1, Win32ShellFolder2 sf2) {
         boolean special1 = sf1.isSpecial();
         boolean special2 = sf2.isSpecial();
 
         if (special1 || special2) {
             if (topFolderList == null) {
-                ArrayList tmpTopFolderList = new ArrayList();
+                ArrayList<Win32ShellFolder2> tmpTopFolderList = new ArrayList<>();
                 tmpTopFolderList.add(Win32ShellFolderManager2.getPersonal());
                 tmpTopFolderList.add(Win32ShellFolderManager2.getDesktop());
                 tmpTopFolderList.add(Win32ShellFolderManager2.getDrives());
--- a/jdk/src/windows/classes/sun/awt/windows/WDragSourceContextPeer.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WDragSourceContextPeer.java	Thu Jun 05 13:59:01 2014 -0700
@@ -29,6 +29,7 @@
 import java.awt.Cursor;
 import java.awt.Image;
 import java.awt.Point;
+import java.awt.datatransfer.DataFlavor;
 import java.awt.image.BufferedImage;
 import java.awt.image.DataBufferInt;
 
@@ -76,8 +77,9 @@
         return theInstance;
     }
 
+    @Override
     protected void startDrag(Transferable trans,
-                             long[] formats, Map formatMap) {
+                             long[] formats, Map<Long, DataFlavor> formatMap) {
 
         long nativeCtxtLocal = 0;
 
@@ -153,7 +155,7 @@
                                  InputEvent nativeTrigger,
                                  int actions,
                                  long[] formats,
-                                 Map formatMap);
+                                 Map<Long, DataFlavor> formatMap);
 
     /**
      * downcall into native code
--- a/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java	Thu Jun 05 13:59:01 2014 -0700
@@ -53,7 +53,7 @@
     @Override
     protected void initReorderMap() {
         if (encoding.equalsIgnoreCase("windows-31j")) {
-            localeMap = new Hashtable();
+            localeMap = new Hashtable<>();
             /* Substitute Mincho for Gothic in this one case.
              * Note the windows fontconfig files already contain the mapping:
              * filename.MS_Mincho=MSMINCHO.TTC
@@ -67,7 +67,7 @@
             localeMap.put("dialoginput.italic.japanese", "MS Mincho");
             localeMap.put("dialoginput.bolditalic.japanese", "MS Mincho");
         }
-        reorderMap = new HashMap();
+        reorderMap = new HashMap<>();
         reorderMap.put("UTF-8.hi", "devanagari");
         reorderMap.put("windows-1255", "hebrew");
         reorderMap.put("x-windows-874", "thai");
@@ -118,7 +118,7 @@
 
     @Override
     protected String makeAWTFontName(String platformFontName, String characterSubsetName) {
-        String windowsCharset = (String) subsetCharsetMap.get(characterSubsetName);
+        String windowsCharset = subsetCharsetMap.get(characterSubsetName);
         if (windowsCharset == null) {
             windowsCharset = "DEFAULT_CHARSET";
         }
@@ -127,7 +127,7 @@
 
     @Override
     protected String getEncoding(String awtFontName, String characterSubsetName) {
-        String encoding = (String) subsetEncodingMap.get(characterSubsetName);
+        String encoding = subsetEncodingMap.get(characterSubsetName);
         if (encoding == null) {
             encoding = "default";
         }
@@ -174,8 +174,8 @@
         return fontName;
     }
 
-    private static HashMap subsetCharsetMap = new HashMap();
-    private static HashMap subsetEncodingMap = new HashMap();
+    private static HashMap<String, String> subsetCharsetMap = new HashMap<>();
+    private static HashMap<String, String> subsetEncodingMap = new HashMap<>();
     private static String textInputCharset;
 
     private void initTables(String defaultEncoding) {
--- a/jdk/src/windows/classes/sun/awt/windows/WFontMetrics.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WFontMetrics.java	Thu Jun 05 13:59:01 2014 -0700
@@ -199,10 +199,10 @@
 
     native void init();
 
-    static Hashtable table = new Hashtable();
+    static Hashtable<Font, FontMetrics> table = new Hashtable<>();
 
     static FontMetrics getFontMetrics(Font font) {
-        FontMetrics fm = (FontMetrics)table.get(font);
+        FontMetrics fm = table.get(font);
         if (fm == null) {
             table.put(font, fm = new WFontMetrics(font));
         }
--- a/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WInputMethod.java	Thu Jun 05 13:59:01 2014 -0700
@@ -86,26 +86,27 @@
 
     // Initialize highlight mapping table
     static {
+        @SuppressWarnings({"rawtypes", "unchecked"})
         Map<TextAttribute,Object> styles[] = new Map[4];
         HashMap<TextAttribute,Object> map;
 
         // UNSELECTED_RAW_TEXT_HIGHLIGHT
-        map = new HashMap(1);
+        map = new HashMap<>(1);
         map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED);
         styles[0] = Collections.unmodifiableMap(map);
 
         // SELECTED_RAW_TEXT_HIGHLIGHT
-        map = new HashMap(1);
+        map = new HashMap<>(1);
         map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_GRAY);
         styles[1] = Collections.unmodifiableMap(map);
 
         // UNSELECTED_CONVERTED_TEXT_HIGHLIGHT
-        map = new HashMap(1);
+        map = new HashMap<>(1);
         map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED);
         styles[2] = Collections.unmodifiableMap(map);
 
         // SELECTED_CONVERTED_TEXT_HIGHLIGHT
-        map = new HashMap(4);
+        map = new HashMap<>(4);
         Color navyBlue = new Color(0, 0, 128);
         map.put(TextAttribute.FOREGROUND, navyBlue);
         map.put(TextAttribute.BACKGROUND, Color.white);
--- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java	Thu Jun 05 13:59:01 2014 -0700
@@ -843,6 +843,7 @@
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     public <T extends DragGestureRecognizer> T
         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
                                     DragSource ds, Component c, int srcActions,
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DBlitLoops.java	Thu Jun 05 13:59:01 2014 -0700
@@ -717,7 +717,7 @@
 class D3DGeneralBlit extends Blit {
 
     private Blit performop;
-    private WeakReference srcTmp;
+    private WeakReference<SurfaceData> srcTmp;
 
     D3DGeneralBlit(SurfaceType dstType,
                    CompositeType compType,
@@ -739,7 +739,7 @@
         SurfaceData cachedSrc = null;
         if (srcTmp != null) {
             // use cached intermediate surface, if available
-            cachedSrc = (SurfaceData)srcTmp.get();
+            cachedSrc = srcTmp.get();
         }
 
         // convert source to IntArgbPre
@@ -752,7 +752,7 @@
 
         if (src != cachedSrc) {
             // cache the intermediate surface
-            srcTmp = new WeakReference(src);
+            srcTmp = new WeakReference<>(src);
         }
     }
 }
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java	Thu Jun 05 13:59:01 2014 -0700
@@ -41,7 +41,6 @@
 import sun.awt.windows.WWindowPeer;
 import sun.java2d.pipe.hw.ContextCapabilities;
 import sun.java2d.windows.WindowsFlags;
-import static sun.java2d.pipe.BufferedOpCodes.*;
 import static sun.java2d.d3d.D3DContext.D3DContextCaps.*;
 import sun.java2d.d3d.D3DContext.D3DContextCaps;
 
@@ -383,9 +382,9 @@
     }
 
     private static native void enumDisplayModesNative(int screen,
-                                                      ArrayList modes);
+                                                      ArrayList<DisplayMode> modes);
     @Override
-    protected void enumDisplayModes(final int screen, final ArrayList modes) {
+    protected void enumDisplayModes(final int screen, final ArrayList<DisplayMode> modes) {
         D3DRenderQueue rq = D3DRenderQueue.getInstance();
         rq.lock();
         try {
--- a/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java	Thu Jun 05 13:59:01 2014 -0700
@@ -75,7 +75,7 @@
     public static final SurfaceType ThreeByteBgrGdi =
         SurfaceType.ThreeByteBgr.deriveSubType(DESC_GDI);
 
-    private static native void initIDs(Class xorComp);
+    private static native void initIDs(Class<?> xorComp);
 
     static {
         initIDs(XORComposite.class);
--- a/jdk/src/windows/classes/sun/java2d/windows/WindowsFlags.java	Wed Jun 11 17:23:56 2014 +0400
+++ b/jdk/src/windows/classes/sun/java2d/windows/WindowsFlags.java	Thu Jun 05 13:59:01 2014 -0700
@@ -201,7 +201,7 @@
 
     private static void initJavaFlags() {
         java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction()
+            new java.security.PrivilegedAction<Object>()
         {
             public Object run() {
                 magPresent = getBooleanProp(