[OpenJDK 2D-Dev] JDK 9 RFR of JDK-8048980 : Fix raw and unchecked lint warnings in platform-specific sun.font files

Joe Darcy joe.darcy at oracle.com
Wed Jul 2 00:35:11 UTC 2014


Hello,

Please review this small change to address a few remaining unchecked and 
raw types warnings in platform-specific sun.font code; full patch below:

     JDK-8048980 : Fix raw and unchecked lint warnings in 
platform-specific sun.font files
     http://cr.openjdk.java.net/~darcy/8048980.0/

Thanks,

-Joe

--- old/src/macosx/classes/sun/font/CFontConfiguration.java 2014-07-01 
17:26:37.000000000 -0700
+++ new/src/macosx/classes/sun/font/CFontConfiguration.java 2014-07-01 
17:26:37.000000000 -0700
@@ -106,6 +106,6 @@

      @Override
      protected void initReorderMap() {
-        reorderMap = new HashMap();
+        reorderMap = new HashMap<>();
      }
  }
--- old/src/solaris/classes/sun/font/FcFontConfiguration.java 2014-07-01 
17:26:37.000000000 -0700
+++ new/src/solaris/classes/sun/font/FcFontConfiguration.java 2014-07-01 
17:26:37.000000000 -0700
@@ -170,7 +170,7 @@

      @Override
      protected void initReorderMap() {
-        reorderMap = new HashMap();
+        reorderMap = new HashMap<>();
      }

      @Override
--- old/src/solaris/classes/sun/font/XMap.java    2014-07-01 
17:26:38.000000000 -0700
+++ new/src/solaris/classes/sun/font/XMap.java    2014-07-01 
17:26:37.000000000 -0700
@@ -37,7 +37,7 @@

  class XMap {

-    private static HashMap xMappers = new HashMap();
+    private static HashMap<String, XMap> xMappers = new HashMap<>();

      /* ConvertedGlyphs has unicode code points as indexes and values
       * are platform-encoded multi-bytes chars packed into java chars.
@@ -49,7 +49,7 @@
      char[] convertedGlyphs;

      static synchronized XMap getXMapper(String encoding) {
-        XMap mapper = (XMap)xMappers.get(encoding);
+        XMap mapper = xMappers.get(encoding);
          if (mapper == null) {
              mapper = getXMapperInternal(encoding);
              xMappers.put(encoding, mapper);
--- old/src/solaris/classes/sun/font/XRGlyphCache.java    2014-07-01 
17:26:38.000000000 -0700
+++ new/src/solaris/classes/sun/font/XRGlyphCache.java    2014-07-01 
17:26:38.000000000 -0700
@@ -190,20 +190,23 @@
          for (XRGlyphCacheEntry cacheEntry : glyphList) {
              if (cacheEntry.isGrayscale(containsLCDGlyphs)) {
                  if (grayGlyphs == null) {
-                    grayGlyphs = new 
ArrayList<XRGlyphCacheEntry>(glyphList.size());
+                    grayGlyphs = new ArrayList<>(glyphList.size());
                  }
                  cacheEntry.setGlyphSet(grayGlyphSet);
                  grayGlyphs.add(cacheEntry);
              } else {
                  if (lcdGlyphs == null) {
-                    lcdGlyphs = new 
ArrayList<XRGlyphCacheEntry>(glyphList.size());
+                    lcdGlyphs = new ArrayList<>(glyphList.size());
                  }
                  cacheEntry.setGlyphSet(lcdGlyphSet);
                  lcdGlyphs.add(cacheEntry);
              }
          }
-
-        return new List[] { grayGlyphs, lcdGlyphs };
+        // Arrays and generics don't play well together
+        @SuppressWarnings({"unchecked", "rawtypes"})
+        List<XRGlyphCacheEntry>[] tmp =
+            (List<XRGlyphCacheEntry>[]) (new List[] { grayGlyphs, 
lcdGlyphs });
+        return tmp;
      }

      /**




More information about the 2d-dev mailing list