From f25fffb5d01197aa7ac6be3b7baa60d5e5fcc0e0 Mon Sep 17 00:00:00 2001 From: art Date: Fri, 11 Oct 2013 16:44:42 +0400 Subject: [PATCH] 8022185: Fix Raw and unchecked warnings in classes belonging to java.awt.datatransfer Reviewed-by: art, pchelko Contributed-by: Srikalyan Chandrashekar --- .../java/awt/datatransfer/DataFlavor.java | 18 +++++----- .../datatransfer/MimeTypeParameterList.java | 34 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/share/classes/java/awt/datatransfer/DataFlavor.java b/src/share/classes/java/awt/datatransfer/DataFlavor.java index ac1403348..733557e3e 100644 --- a/src/share/classes/java/awt/datatransfer/DataFlavor.java +++ b/src/share/classes/java/awt/datatransfer/DataFlavor.java @@ -101,7 +101,7 @@ import sun.awt.datatransfer.DataTransferer; public class DataFlavor implements Externalizable, Cloneable { private static final long serialVersionUID = 8367026044764648243L; - private static final Class ioInputStreamClass = java.io.InputStream.class; + private static final Class ioInputStreamClass = InputStream.class; /** * Tries to load a class from: the bootstrap loader, the system loader, @@ -116,10 +116,10 @@ public class DataFlavor implements Externalizable, Cloneable { ClassLoader fallback) throws ClassNotFoundException { - ClassLoader systemClassLoader = (ClassLoader) + ClassLoader systemClassLoader = java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + new java.security.PrivilegedAction() { + public ClassLoader run() { ClassLoader cl = Thread.currentThread(). getContextClassLoader(); return (cl != null) @@ -142,7 +142,7 @@ public class DataFlavor implements Externalizable, Cloneable { /* * private initializer */ - static private DataFlavor createConstant(Class rc, String prn) { + static private DataFlavor createConstant(Class rc, String prn) { try { return new DataFlavor(rc, prn); } catch (Exception e) { @@ -314,7 +314,7 @@ public class DataFlavor implements Externalizable, Cloneable { * @exception NullPointerException if either primaryType, * subType or representationClass is null */ - private DataFlavor(String primaryType, String subType, MimeTypeParameterList params, Class representationClass, String humanPresentableName) { + private DataFlavor(String primaryType, String subType, MimeTypeParameterList params, Class representationClass, String humanPresentableName) { super(); if (primaryType == null) { throw new NullPointerException("primaryType"); @@ -331,7 +331,7 @@ public class DataFlavor implements Externalizable, Cloneable { params.set("class", representationClass.getName()); if (humanPresentableName == null) { - humanPresentableName = (String)params.get("humanPresentableName"); + humanPresentableName = params.get("humanPresentableName"); if (humanPresentableName == null) humanPresentableName = primaryType + "/" + subType; @@ -732,7 +732,7 @@ public class DataFlavor implements Externalizable, Cloneable { return bestFlavor; } - private static Comparator textFlavorComparator; + private static Comparator textFlavorComparator; static class TextFlavorComparator extends DataTransferer.DataFlavorComparator { @@ -1438,6 +1438,6 @@ public class DataFlavor implements Externalizable, Cloneable { /** Java class of objects this DataFlavor represents **/ - private Class representationClass; + private Class representationClass; } // class DataFlavor diff --git a/src/share/classes/java/awt/datatransfer/MimeTypeParameterList.java b/src/share/classes/java/awt/datatransfer/MimeTypeParameterList.java index 80947d9ea..bce187176 100644 --- a/src/share/classes/java/awt/datatransfer/MimeTypeParameterList.java +++ b/src/share/classes/java/awt/datatransfer/MimeTypeParameterList.java @@ -44,13 +44,13 @@ class MimeTypeParameterList implements Cloneable { * Default constructor. */ public MimeTypeParameterList() { - parameters = new Hashtable(); + parameters = new Hashtable<>(); } public MimeTypeParameterList(String rawdata) throws MimeTypeParseException { - parameters = new Hashtable(); + parameters = new Hashtable<>(); // now parse rawdata parse(rawdata); @@ -59,10 +59,10 @@ class MimeTypeParameterList implements Cloneable { public int hashCode() { int code = Integer.MAX_VALUE/45; // "random" value for empty lists String paramName = null; - Enumeration enum_ = this.getNames(); + Enumeration enum_ = this.getNames(); while (enum_.hasMoreElements()) { - paramName = (String)enum_.nextElement(); + paramName = enum_.nextElement(); code += paramName.hashCode(); code += this.get(paramName).hashCode(); } @@ -87,14 +87,14 @@ class MimeTypeParameterList implements Cloneable { String name = null; String thisValue = null; String thatValue = null; - Set entries = parameters.entrySet(); - Iterator iterator = entries.iterator(); - Map.Entry entry = null; + Set> entries = parameters.entrySet(); + Iterator> iterator = entries.iterator(); + Map.Entry entry = null; while (iterator.hasNext()) { - entry = (Map.Entry)iterator.next(); - name = (String)entry.getKey(); - thisValue = (String)entry.getValue(); - thatValue = (String)that.parameters.get(name); + entry = iterator.next(); + name = entry.getKey(); + thisValue = entry.getValue(); + thatValue = that.parameters.get(name); if ((thisValue == null) || (thatValue == null)) { // both null -> equal, only one null -> not equal if (thisValue != thatValue) { @@ -250,7 +250,7 @@ class MimeTypeParameterList implements Cloneable { * is no current association. */ public String get(String name) { - return (String)parameters.get(name.trim().toLowerCase()); + return parameters.get(name.trim().toLowerCase()); } /** @@ -271,7 +271,7 @@ class MimeTypeParameterList implements Cloneable { /** * Retrieve an enumeration of all the names in this list. */ - public Enumeration getNames() { + public Enumeration getNames() { return parameters.keys(); } @@ -279,15 +279,15 @@ class MimeTypeParameterList implements Cloneable { // Heuristic: 8 characters per field StringBuilder buffer = new StringBuilder(parameters.size() * 16); - Enumeration keys = parameters.keys(); + Enumeration keys = parameters.keys(); while(keys.hasMoreElements()) { buffer.append("; "); - String key = (String)keys.nextElement(); + String key = keys.nextElement(); buffer.append(key); buffer.append('='); - buffer.append(quote((String)parameters.get(key))); + buffer.append(quote(parameters.get(key))); } return buffer.toString(); @@ -307,7 +307,7 @@ class MimeTypeParameterList implements Cloneable { return newObj; } - private Hashtable parameters; + private Hashtable parameters; // below here be scary parsing related things -- GitLab