8022185: Fix Raw and unchecked warnings in classes belonging to java.awt.datatransfer
Reviewed-by: art, pchelko
Contributed-by: Srikalyan Chandrashekar <srikalyan.chandrashekar@oracle.com>
--- a/jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Fri Oct 11 15:39:40 2013 +0400
+++ b/jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Fri Oct 11 16:44:42 2013 +0400
@@ -101,7 +101,7 @@
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<InputStream> ioInputStreamClass = InputStream.class;
/**
* Tries to load a class from: the bootstrap loader, the system loader,
@@ -116,10 +116,10 @@
ClassLoader fallback)
throws ClassNotFoundException
{
- ClassLoader systemClassLoader = (ClassLoader)
+ ClassLoader systemClassLoader =
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ new java.security.PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
ClassLoader cl = Thread.currentThread().
getContextClassLoader();
return (cl != null)
@@ -142,7 +142,7 @@
/*
* 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 @@
* @exception NullPointerException if either <code>primaryType</code>,
* <code>subType</code> or <code>representationClass</code> 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 @@
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 @@
return bestFlavor;
}
- private static Comparator textFlavorComparator;
+ private static Comparator<DataFlavor> textFlavorComparator;
static class TextFlavorComparator
extends DataTransferer.DataFlavorComparator {
@@ -1438,6 +1438,6 @@
/** Java class of objects this DataFlavor represents **/
- private Class representationClass;
+ private Class<?> representationClass;
} // class DataFlavor
--- a/jdk/src/share/classes/java/awt/datatransfer/MimeTypeParameterList.java Fri Oct 11 15:39:40 2013 +0400
+++ b/jdk/src/share/classes/java/awt/datatransfer/MimeTypeParameterList.java Fri Oct 11 16:44:42 2013 +0400
@@ -44,13 +44,13 @@
* 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 @@
public int hashCode() {
int code = Integer.MAX_VALUE/45; // "random" value for empty lists
String paramName = null;
- Enumeration enum_ = this.getNames();
+ Enumeration<String> 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 @@
String name = null;
String thisValue = null;
String thatValue = null;
- Set entries = parameters.entrySet();
- Iterator iterator = entries.iterator();
- Map.Entry entry = null;
+ Set<Map.Entry<String, String>> entries = parameters.entrySet();
+ Iterator<Map.Entry<String, String>> iterator = entries.iterator();
+ Map.Entry<String, String> 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 @@
* 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 @@
/**
* Retrieve an enumeration of all the names in this list.
*/
- public Enumeration getNames() {
+ public Enumeration<String> getNames() {
return parameters.keys();
}
@@ -279,15 +279,15 @@
// Heuristic: 8 characters per field
StringBuilder buffer = new StringBuilder(parameters.size() * 16);
- Enumeration keys = parameters.keys();
+ Enumeration<String> 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 @@
return newObj;
}
- private Hashtable parameters;
+ private Hashtable<String, String> parameters;
// below here be scary parsing related things