changeset 4807:3b8186aee592

7116722: Miscellaneous warnings sun.misc ( and related classes ) Reviewed-by: alanb, darcy, forax, hawtin, lancea
author chegar
date Thu, 01 Dec 2011 11:09:54 +0000
parents 43a630f11af6
children 89130611b178
files src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java src/share/classes/java/net/InetAddress.java src/share/classes/java/util/jar/JarVerifier.java src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java src/share/classes/javax/script/ScriptEngineManager.java src/share/classes/sun/misc/BASE64Decoder.java src/share/classes/sun/misc/ExtensionDependency.java src/share/classes/sun/misc/JarIndex.java src/share/classes/sun/misc/JavaUtilJarAccess.java src/share/classes/sun/misc/ProxyGenerator.java src/share/classes/sun/misc/Service.java src/share/classes/sun/misc/Signal.java test/sun/misc/JarIndex/metaInfFilenames/Basic.java
diffstat 13 files changed, 116 insertions(+), 114 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java	Thu Dec 01 11:09:54 2011 +0000
@@ -31,7 +31,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Iterator;
-import sun.misc.Service;
+import java.util.ServiceLoader;
 import sun.misc.ServiceConfigurationError;
 import sun.security.action.GetPropertyAction;
 import com.sun.net.httpserver.*;
@@ -94,9 +94,10 @@
     }
 
     private static boolean loadProviderAsService() {
-        @SuppressWarnings("unchecked")
-        Iterator<HttpServerProvider> i = Service.providers(HttpServerProvider.class,
-                                       ClassLoader.getSystemClassLoader());
+        Iterator<HttpServerProvider> i =
+            ServiceLoader.load(HttpServerProvider.class,
+                                ClassLoader.getSystemClassLoader())
+                .iterator();
         for (;;) {
             try {
                 if (!i.hasNext())
--- a/src/share/classes/java/net/InetAddress.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/java/net/InetAddress.java	Thu Dec 01 11:09:54 2011 +0000
@@ -32,6 +32,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.ServiceLoader;
 import java.security.AccessController;
 import java.io.ObjectStreamException;
 import java.io.IOException;
@@ -39,7 +40,6 @@
 import sun.security.action.*;
 import sun.net.InetAddressCachePolicy;
 import sun.net.util.IPAddressUtil;
-import sun.misc.Service;
 import sun.net.spi.nameservice.*;
 
 /**
@@ -876,10 +876,9 @@
                 nameService = java.security.AccessController.doPrivileged(
                     new java.security.PrivilegedExceptionAction<NameService>() {
                         public NameService run() {
-                            // sun.misc.Service.providers returns a raw Iterator
-                            @SuppressWarnings("unchecked")
                             Iterator<NameServiceDescriptor> itr =
-                                Service.providers(NameServiceDescriptor.class);
+                                ServiceLoader.load(NameServiceDescriptor.class)
+                                    .iterator();
                             while (itr.hasNext()) {
                                 NameServiceDescriptor nsd = itr.next();
                                 if (providerName.
--- a/src/share/classes/java/util/jar/JarVerifier.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/java/util/jar/JarVerifier.java	Thu Dec 01 11:09:54 2011 +0000
@@ -90,7 +90,7 @@
     private Object csdomain = new Object();
 
     /** collect -DIGEST-MANIFEST values for blacklist */
-    private List manifestDigests;
+    private List<Object> manifestDigests;
 
     public JarVerifier(byte rawBytes[]) {
         manifestRawBytes = rawBytes;
@@ -99,7 +99,7 @@
         sigFileData = new Hashtable(11);
         pendingBlocks = new ArrayList();
         baos = new ByteArrayOutputStream();
-        manifestDigests = new ArrayList();
+        manifestDigests = new ArrayList<>();
     }
 
     /**
@@ -872,7 +872,7 @@
         eagerValidation = eager;
     }
 
-    public synchronized List getManifestDigests() {
+    public synchronized List<Object> getManifestDigests() {
         return Collections.unmodifiableList(manifestDigests);
     }
 
--- a/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Thu Dec 01 11:09:54 2011 +0000
@@ -57,7 +57,7 @@
         jar.setEagerValidation(eager);
     }
 
-    public List getManifestDigests(JarFile jar) {
+    public List<Object> getManifestDigests(JarFile jar) {
         return jar.getManifestDigests();
     }
 }
--- a/src/share/classes/javax/script/ScriptEngineManager.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/javax/script/ScriptEngineManager.java	Thu Dec 01 11:09:54 2011 +0000
@@ -102,7 +102,7 @@
     }
 
     private void initEngines(final ClassLoader loader) {
-        Iterator itr = null;
+        Iterator<ScriptEngineFactory> itr = null;
         try {
             if (loader != null) {
                 itr = Service.providers(ScriptEngineFactory.class, loader);
@@ -124,7 +124,7 @@
         try {
             while (itr.hasNext()) {
                 try {
-                    ScriptEngineFactory fact = (ScriptEngineFactory) itr.next();
+                    ScriptEngineFactory fact = itr.next();
                     engineSpis.add(fact);
                 } catch (ServiceConfigurationError err) {
                     System.err.println("ScriptEngineManager providers.next(): "
@@ -441,7 +441,7 @@
     // Note that this code is same as ClassLoader.getCallerClassLoader().
     // But, that method is package private and hence we can't call here.
     private ClassLoader getCallerClassLoader() {
-        Class caller = Reflection.getCallerClass(3);
+        Class<?> caller = Reflection.getCallerClass(3);
         if (caller == null) {
             return null;
         }
--- a/src/share/classes/sun/misc/BASE64Decoder.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/sun/misc/BASE64Decoder.java	Thu Dec 01 11:09:54 2011 +0000
@@ -102,6 +102,7 @@
     /**
      * Decode one BASE64 atom into 1, 2, or 3 bytes of data.
      */
+    @SuppressWarnings("fallthrough")
     protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int rem)
         throws java.io.IOException
     {
--- a/src/share/classes/sun/misc/ExtensionDependency.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/sun/misc/ExtensionDependency.java	Thu Dec 01 11:09:54 2011 +0000
@@ -70,7 +70,7 @@
 public class ExtensionDependency {
 
     /* Callbak interfaces to delegate installation of missing extensions */
-    private static Vector providers;
+    private static Vector<ExtensionInstallationProvider> providers;
 
     /**
      * <p>
@@ -83,7 +83,7 @@
         (ExtensionInstallationProvider eip)
     {
         if (providers == null) {
-            providers = new Vector();
+            providers = new Vector<>();
         }
         providers.add(eip);
     }
@@ -93,7 +93,7 @@
      * Unregister a previously installed installation provider
      * </p>
      */
-    public synchronized  static void removeExtensionInstallationProvider
+    public synchronized static void removeExtensionInstallationProvider
         (ExtensionInstallationProvider eip)
     {
         providers.remove(eip);
@@ -348,14 +348,16 @@
                                        ExtensionInfo instInfo)
         throws ExtensionInstallationException
     {
-
-        Vector currentProviders;
+        Vector<ExtensionInstallationProvider> currentProviders;
         synchronized(providers) {
-            currentProviders = (Vector) providers.clone();
+            @SuppressWarnings("unchecked")
+            Vector<ExtensionInstallationProvider> tmp =
+                (Vector<ExtensionInstallationProvider>) providers.clone();
+            currentProviders = tmp;
         }
-        for (Enumeration e=currentProviders.elements();e.hasMoreElements();) {
-            ExtensionInstallationProvider eip =
-                (ExtensionInstallationProvider) e.nextElement();
+        for (Enumeration<ExtensionInstallationProvider> e = currentProviders.elements();
+                e.hasMoreElements();) {
+            ExtensionInstallationProvider eip = e.nextElement();
 
             if (eip!=null) {
                 // delegate the installation to the provider
--- a/src/share/classes/sun/misc/JarIndex.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/sun/misc/JarIndex.java	Thu Dec 01 11:09:54 2011 +0000
@@ -48,13 +48,13 @@
      * The hash map that maintains mappings from
      * package/classe/resource to jar file list(s)
      */
-    private HashMap indexMap;
+    private HashMap<String,LinkedList<String>> indexMap;
 
     /**
      * The hash map that maintains mappings from
      * jar file to package/class/resource lists
      */
-    private HashMap jarMap;
+    private HashMap<String,LinkedList<String>> jarMap;
 
     /*
      * An ordered list of jar file names.
@@ -78,8 +78,8 @@
      * Constructs a new, empty jar index.
      */
     public JarIndex() {
-        indexMap = new HashMap();
-        jarMap = new HashMap();
+        indexMap = new HashMap<>();
+        jarMap = new HashMap<>();
     }
 
     /**
@@ -150,10 +150,11 @@
      * Add the key, value pair to the hashmap, the value will
      * be put in a linked list which is created if necessary.
      */
-    private void addToList(String key, String value, HashMap t) {
-        LinkedList list = (LinkedList)t.get(key);
+    private void addToList(String key, String value,
+                           HashMap<String,LinkedList<String>> t) {
+        LinkedList<String> list = t.get(key);
         if (list == null) {
-            list = new LinkedList();
+            list = new LinkedList<>();
             list.add(value);
             t.put(key, list);
         } else if (!list.contains(value)) {
@@ -166,13 +167,13 @@
      *
      * @param fileName the key of the mapping
      */
-    public LinkedList get(String fileName) {
-        LinkedList jarFiles = null;
-        if ((jarFiles = (LinkedList)indexMap.get(fileName)) == null) {
+    public LinkedList<String> get(String fileName) {
+        LinkedList<String> jarFiles = null;
+        if ((jarFiles = indexMap.get(fileName)) == null) {
             /* try the package name again */
             int pos;
             if((pos = fileName.lastIndexOf("/")) != -1) {
-                jarFiles = (LinkedList)indexMap.get(fileName.substring(0, pos));
+                jarFiles = indexMap.get(fileName.substring(0, pos));
             }
         }
         return jarFiles;
@@ -235,9 +236,9 @@
             ZipFile zrf = new ZipFile(currentJar.replace
                                       ('/', File.separatorChar));
 
-            Enumeration entries = zrf.entries();
+            Enumeration<? extends ZipEntry> entries = zrf.entries();
             while(entries.hasMoreElements()) {
-                ZipEntry entry = (ZipEntry) entries.nextElement();
+                ZipEntry entry = entries.nextElement();
                 String fileName = entry.getName();
 
                 // Skip the META-INF directory, the index, and manifest.
@@ -282,11 +283,11 @@
                 /* print out the jar file name */
                 String jar = jarFiles[i];
                 bw.write(jar + "\n");
-                LinkedList jarlist = (LinkedList)jarMap.get(jar);
+                LinkedList<String> jarlist = jarMap.get(jar);
                 if (jarlist != null) {
-                    Iterator listitr = jarlist.iterator();
+                    Iterator<String> listitr = jarlist.iterator();
                     while(listitr.hasNext()) {
-                        bw.write((String)(listitr.next()) + "\n");
+                        bw.write(listitr.next() + "\n");
                     }
                 }
                 bw.write("\n");
@@ -309,7 +310,7 @@
         String currentJar = null;
 
         /* an ordered list of jar file names */
-        Vector jars = new Vector();
+        Vector<String> jars = new Vector<>();
 
         /* read until we see a .jar line */
         while((line = br.readLine()) != null && !line.endsWith(".jar"));
@@ -328,7 +329,7 @@
             }
         }
 
-        jarFiles = (String[])jars.toArray(new String[jars.size()]);
+        jarFiles = jars.toArray(new String[jars.size()]);
     }
 
     /**
@@ -342,14 +343,14 @@
      *
      */
     public void merge(JarIndex toIndex, String path) {
-        Iterator itr = indexMap.entrySet().iterator();
+        Iterator<Map.Entry<String,LinkedList<String>>> itr = indexMap.entrySet().iterator();
         while(itr.hasNext()) {
-            Map.Entry e = (Map.Entry)itr.next();
-            String packageName = (String)e.getKey();
-            LinkedList from_list = (LinkedList)e.getValue();
-            Iterator listItr = from_list.iterator();
+            Map.Entry<String,LinkedList<String>> e = itr.next();
+            String packageName = e.getKey();
+            LinkedList<String> from_list = e.getValue();
+            Iterator<String> listItr = from_list.iterator();
             while(listItr.hasNext()) {
-                String jarName = (String)listItr.next();
+                String jarName = listItr.next();
                 if (path != null) {
                     jarName = path.concat(jarName);
                 }
--- a/src/share/classes/sun/misc/JavaUtilJarAccess.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/sun/misc/JavaUtilJarAccess.java	Thu Dec 01 11:09:54 2011 +0000
@@ -40,5 +40,5 @@
     public Enumeration<String> entryNames(JarFile jar, CodeSource[] cs);
     public Enumeration<JarEntry> entries2(JarFile jar);
     public void setEagerValidation(JarFile jar, boolean eager);
-    public List getManifestDigests(JarFile jar);
+    public List<Object> getManifestDigests(JarFile jar);
 }
--- a/src/share/classes/sun/misc/ProxyGenerator.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/sun/misc/ProxyGenerator.java	Thu Dec 01 11:09:54 2011 +0000
@@ -351,7 +351,7 @@
         try {
             hashCodeMethod = Object.class.getMethod("hashCode");
             equalsMethod =
-                Object.class.getMethod("equals", new Class[] { Object.class });
+                Object.class.getMethod("equals", new Class<?>[] { Object.class });
             toStringMethod = Object.class.getMethod("toString");
         } catch (NoSuchMethodException e) {
             throw new NoSuchMethodError(e.getMessage());
@@ -559,11 +559,11 @@
      * passed to the invocation handler's "invoke" method for a given
      * set of duplicate methods.
      */
-    private void addProxyMethod(Method m, Class fromClass) {
+    private void addProxyMethod(Method m, Class<?> fromClass) {
         String name = m.getName();
-        Class[] parameterTypes = m.getParameterTypes();
-        Class returnType = m.getReturnType();
-        Class[] exceptionTypes = m.getExceptionTypes();
+        Class<?>[] parameterTypes = m.getParameterTypes();
+        Class<?> returnType = m.getReturnType();
+        Class<?>[] exceptionTypes = m.getExceptionTypes();
 
         String sig = name + getParameterDescriptors(parameterTypes);
         List<ProxyMethod> sigmethods = proxyMethods.get(sig);
@@ -581,7 +581,7 @@
                         exceptionTypes, pm.exceptionTypes, legalExceptions);
                     collectCompatibleTypes(
                         pm.exceptionTypes, exceptionTypes, legalExceptions);
-                    pm.exceptionTypes = new Class[legalExceptions.size()];
+                    pm.exceptionTypes = new Class<?>[legalExceptions.size()];
                     pm.exceptionTypes =
                         legalExceptions.toArray(pm.exceptionTypes);
                     return;
@@ -848,15 +848,15 @@
     private class ProxyMethod {
 
         public String methodName;
-        public Class[] parameterTypes;
-        public Class returnType;
-        public Class[] exceptionTypes;
-        public Class fromClass;
+        public Class<?>[] parameterTypes;
+        public Class<?> returnType;
+        public Class<?>[] exceptionTypes;
+        public Class<?> fromClass;
         public String methodFieldName;
 
-        private ProxyMethod(String methodName, Class[] parameterTypes,
-                            Class returnType, Class[] exceptionTypes,
-                            Class fromClass)
+        private ProxyMethod(String methodName, Class<?>[] parameterTypes,
+                            Class<?> returnType, Class<?>[] exceptionTypes,
+                            Class<?> fromClass)
         {
             this.methodName = methodName;
             this.parameterTypes = parameterTypes;
@@ -1001,7 +1001,7 @@
          * invocation handler's "invoke" method.  The code is written
          * to the supplied stream.
          */
-        private void codeWrapArgument(Class type, int slot,
+        private void codeWrapArgument(Class<?> type, int slot,
                                       DataOutputStream out)
             throws IOException
         {
@@ -1042,7 +1042,7 @@
          * Object) to its correct type.  The code is written to the
          * supplied stream.
          */
-        private void codeUnwrapReturnValue(Class type, DataOutputStream out)
+        private void codeUnwrapReturnValue(Class<?> type, DataOutputStream out)
             throws IOException
         {
             if (type.isPrimitive()) {
@@ -1391,7 +1391,7 @@
      * the supplied stream.  Note that the code generated by this method
      * may caused the checked ClassNotFoundException to be thrown.
      */
-    private void codeClassForName(Class cl, DataOutputStream out)
+    private void codeClassForName(Class<?> cl, DataOutputStream out)
         throws IOException
     {
         code_ldc(cp.getString(cl.getName()), out);
@@ -1422,8 +1422,8 @@
      * Return the "method descriptor" string for a method with the given
      * parameter types and return type.  See JVMS section 4.3.3.
      */
-    private static String getMethodDescriptor(Class[] parameterTypes,
-                                              Class returnType)
+    private static String getMethodDescriptor(Class<?>[] parameterTypes,
+                                              Class<?> returnType)
     {
         return getParameterDescriptors(parameterTypes) +
             ((returnType == void.class) ? "V" : getFieldType(returnType));
@@ -1436,7 +1436,7 @@
      * string is useful for constructing string keys for methods without
      * regard to their return type.
      */
-    private static String getParameterDescriptors(Class[] parameterTypes) {
+    private static String getParameterDescriptors(Class<?>[] parameterTypes) {
         StringBuilder desc = new StringBuilder("(");
         for (int i = 0; i < parameterTypes.length; i++) {
             desc.append(getFieldType(parameterTypes[i]));
@@ -1450,7 +1450,7 @@
      * a field descriptor, a parameter descriptor, or a return descriptor
      * other than "void".  See JVMS section 4.3.2.
      */
-    private static String getFieldType(Class type) {
+    private static String getFieldType(Class<?> type) {
         if (type.isPrimitive()) {
             return PrimitiveTypeInfo.get(type).baseTypeString;
         } else if (type.isArray()) {
@@ -1472,7 +1472,7 @@
      * method with the given name and parameter types.
      */
     private static String getFriendlyMethodSignature(String name,
-                                                     Class[] parameterTypes)
+                                                     Class<?>[] parameterTypes)
     {
         StringBuilder sig = new StringBuilder(name);
         sig.append('(');
@@ -1480,7 +1480,7 @@
             if (i > 0) {
                 sig.append(',');
             }
-            Class parameterType = parameterTypes[i];
+            Class<?> parameterType = parameterTypes[i];
             int dimensions = 0;
             while (parameterType.isArray()) {
                 parameterType = parameterType.getComponentType();
@@ -1504,7 +1504,7 @@
      * this abstract notion of a "word" in section 3.4, but that definition
      * was removed for the second edition.
      */
-    private static int getWordsPerType(Class type) {
+    private static int getWordsPerType(Class<?> type) {
         if (type == long.class || type == double.class) {
             return 2;
         } else {
@@ -1632,8 +1632,7 @@
         /** descriptor of same method */
         public String unwrapMethodDesc;
 
-        private static Map<Class,PrimitiveTypeInfo> table =
-            new HashMap<Class,PrimitiveTypeInfo>();
+        private static Map<Class<?>,PrimitiveTypeInfo> table = new HashMap<>();
         static {
             add(byte.class, Byte.class);
             add(char.class, Character.class);
@@ -1645,12 +1644,12 @@
             add(boolean.class, Boolean.class);
         }
 
-        private static void add(Class primitiveClass, Class wrapperClass) {
+        private static void add(Class<?> primitiveClass, Class<?> wrapperClass) {
             table.put(primitiveClass,
                       new PrimitiveTypeInfo(primitiveClass, wrapperClass));
         }
 
-        private PrimitiveTypeInfo(Class primitiveClass, Class wrapperClass) {
+        private PrimitiveTypeInfo(Class<?> primitiveClass, Class<?> wrapperClass) {
             assert primitiveClass.isPrimitive();
 
             baseTypeString =
@@ -1663,7 +1662,7 @@
             unwrapMethodDesc = "()" + baseTypeString;
         }
 
-        public static PrimitiveTypeInfo get(Class cl) {
+        public static PrimitiveTypeInfo get(Class<?> cl) {
             return table.get(cl);
         }
     }
@@ -1694,7 +1693,7 @@
          * and for assigning the next index value.  Note that element 0
          * of this list corresponds to constant pool index 1.
          */
-        private List<Entry> pool = new ArrayList<Entry>(32);
+        private List<Entry> pool = new ArrayList<>(32);
 
         /**
          * maps constant pool data of all types to constant pool indexes.
@@ -1702,7 +1701,7 @@
          * This map is used to look up the index of an existing entry for
          * values of all types.
          */
-        private Map<Object,Short> map = new HashMap<Object,Short>(16);
+        private Map<Object,Short> map = new HashMap<>(16);
 
         /** true if no new constant pool entries may be added */
         private boolean readOnly = false;
--- a/src/share/classes/sun/misc/Service.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/sun/misc/Service.java	Thu Dec 01 11:09:54 2011 +0000
@@ -125,13 +125,13 @@
  * @since 1.3
  */
 
-public final class Service {
+public final class Service<S> {
 
     private static final String prefix = "META-INF/services/";
 
     private Service() { }
 
-    private static void fail(Class service, String msg, Throwable cause)
+    private static void fail(Class<?> service, String msg, Throwable cause)
         throws ServiceConfigurationError
     {
         ServiceConfigurationError sce
@@ -140,13 +140,13 @@
         throw sce;
     }
 
-    private static void fail(Class service, String msg)
+    private static void fail(Class<?> service, String msg)
         throws ServiceConfigurationError
     {
         throw new ServiceConfigurationError(service.getName() + ": " + msg);
     }
 
-    private static void fail(Class service, URL u, int line, String msg)
+    private static void fail(Class<?> service, URL u, int line, String msg)
         throws ServiceConfigurationError
     {
         fail(service, u + ":" + line + ": " + msg);
@@ -157,8 +157,8 @@
      * on the line to both the names list and the returned set iff the name is
      * not already a member of the returned set.
      */
-    private static int parseLine(Class service, URL u, BufferedReader r, int lc,
-                                 List names, Set returned)
+    private static int parseLine(Class<?> service, URL u, BufferedReader r, int lc,
+                                 List<String> names, Set<String> returned)
         throws IOException, ServiceConfigurationError
     {
         String ln = r.readLine();
@@ -211,12 +211,12 @@
      *         If an I/O error occurs while reading from the given URL, or
      *         if a configuration-file format error is detected
      */
-    private static Iterator parse(Class service, URL u, Set returned)
+    private static Iterator<String> parse(Class<?> service, URL u, Set<String> returned)
         throws ServiceConfigurationError
     {
         InputStream in = null;
         BufferedReader r = null;
-        ArrayList names = new ArrayList();
+        ArrayList<String> names = new ArrayList<>();
         try {
             in = u.openStream();
             r = new BufferedReader(new InputStreamReader(in, "utf-8"));
@@ -239,16 +239,16 @@
     /**
      * Private inner class implementing fully-lazy provider lookup
      */
-    private static class LazyIterator implements Iterator {
+    private static class LazyIterator<S> implements Iterator<S> {
 
-        Class service;
+        Class<S> service;
         ClassLoader loader;
-        Enumeration configs = null;
-        Iterator pending = null;
-        Set returned = new TreeSet();
+        Enumeration<URL> configs = null;
+        Iterator<String> pending = null;
+        Set<String> returned = new TreeSet<>();
         String nextName = null;
 
-        private LazyIterator(Class service, ClassLoader loader) {
+        private LazyIterator(Class<S> service, ClassLoader loader) {
             this.service = service;
             this.loader = loader;
         }
@@ -272,20 +272,20 @@
                 if (!configs.hasMoreElements()) {
                     return false;
                 }
-                pending = parse(service, (URL)configs.nextElement(), returned);
+                pending = parse(service, configs.nextElement(), returned);
             }
-            nextName = (String)pending.next();
+            nextName = pending.next();
             return true;
         }
 
-        public Object next() throws ServiceConfigurationError {
+        public S next() throws ServiceConfigurationError {
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
             String cn = nextName;
             nextName = null;
             try {
-                return Class.forName(cn, true, loader).newInstance();
+                return service.cast(Class.forName(cn, true, loader).newInstance());
             } catch (ClassNotFoundException x) {
                 fail(service,
                      "Provider " + cn + " not found");
@@ -342,10 +342,10 @@
      * @see #providers(java.lang.Class)
      * @see #installedProviders(java.lang.Class)
      */
-    public static Iterator providers(Class service, ClassLoader loader)
+    public static <S> Iterator<S> providers(Class<S> service, ClassLoader loader)
         throws ServiceConfigurationError
     {
-        return new LazyIterator(service, loader);
+        return new LazyIterator<S>(service, loader);
     }
 
 
@@ -374,7 +374,7 @@
      *
      * @see #providers(java.lang.Class, java.lang.ClassLoader)
      */
-    public static Iterator providers(Class service)
+    public static <S> Iterator<S> providers(Class<S> service)
         throws ServiceConfigurationError
     {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
@@ -411,7 +411,7 @@
      *
      * @see #providers(java.lang.Class, java.lang.ClassLoader)
      */
-    public static Iterator installedProviders(Class service)
+    public static <S> Iterator<S> installedProviders(Class<S> service)
         throws ServiceConfigurationError
     {
         ClassLoader cl = ClassLoader.getSystemClassLoader();
--- a/src/share/classes/sun/misc/Signal.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/src/share/classes/sun/misc/Signal.java	Thu Dec 01 11:09:54 2011 +0000
@@ -72,8 +72,8 @@
  * @since    1.2
  */
 public final class Signal {
-    private static Hashtable handlers = new Hashtable(4);
-    private static Hashtable signals = new Hashtable(4);
+    private static Hashtable<Signal,SignalHandler> handlers = new Hashtable<>(4);
+    private static Hashtable<Integer,Signal> signals = new Hashtable<>(4);
 
     private int number;
     private String name;
@@ -166,9 +166,9 @@
             throw new IllegalArgumentException
                 ("Signal already used by VM or OS: " + sig);
         }
-        signals.put(new Integer(sig.number), sig);
+        signals.put(sig.number, sig);
         synchronized (handlers) {
-            SignalHandler oldHandler = (SignalHandler)handlers.get(sig);
+            SignalHandler oldHandler = handlers.get(sig);
             handlers.remove(sig);
             if (newH == 2) {
                 handlers.put(sig, handler);
@@ -200,8 +200,8 @@
 
     /* Called by the VM to execute Java signal handlers. */
     private static void dispatch(final int number) {
-        final Signal sig = (Signal)signals.get(new Integer(number));
-        final SignalHandler handler = (SignalHandler)handlers.get(sig);
+        final Signal sig = signals.get(number);
+        final SignalHandler handler = handlers.get(sig);
 
         Runnable runnable = new Runnable () {
             public void run() {
--- a/test/sun/misc/JarIndex/metaInfFilenames/Basic.java	Wed Nov 30 13:11:16 2011 -0800
+++ b/test/sun/misc/JarIndex/metaInfFilenames/Basic.java	Thu Dec 01 11:09:54 2011 +0000
@@ -154,8 +154,7 @@
     /* run javac <args> */
     static void compile(String... args) {
         debug("Running: javac " + Arrays.toString(args));
-        com.sun.tools.javac.Main compiler = new com.sun.tools.javac.Main();
-        if (compiler.compile(args) != 0) {
+        if (com.sun.tools.javac.Main.compile(args) != 0) {
              throw new RuntimeException("javac failed: args=" + Arrays.toString(args));
         }
     }
@@ -259,7 +258,7 @@
         URLClassLoader loader = getLoader(baseURL);
         httpServer.reset();
 
-        Class messageServiceClass = null;
+        Class<?> messageServiceClass = null;
         try {
             messageServiceClass = loader.loadClass(serviceClass);
         } catch (ClassNotFoundException cnfe) {
@@ -267,7 +266,7 @@
             throw new RuntimeException("Error in test: " + cnfe);
         }
 
-        Iterator<Class<?>> iterator = sun.misc.Service.providers(messageServiceClass, loader);
+        Iterator<?> iterator = sun.misc.Service.providers(messageServiceClass, loader);
         if (expectToFind && !iterator.hasNext()) {
             debug(messageServiceClass + " NOT found.");
             return false;
@@ -301,7 +300,7 @@
         URLClassLoader loader = getLoader(baseURL);
         httpServer.reset();
 
-        Class messageServiceClass = null;
+        Class<?> messageServiceClass = null;
         try {
             messageServiceClass = loader.loadClass(serviceClass);
         } catch (ClassNotFoundException cnfe) {
@@ -309,7 +308,7 @@
             throw new RuntimeException("Error in test: " + cnfe);
         }
 
-        Iterator<Class<?>> iterator = (ServiceLoader.load(messageServiceClass, loader)).iterator();
+        Iterator<?> iterator = (ServiceLoader.load(messageServiceClass, loader)).iterator();
         if (expectToFind && !iterator.hasNext()) {
             debug(messageServiceClass + " NOT found.");
             return false;
@@ -345,7 +344,7 @@
         URLClassLoader loader = getLoader(baseURL);
         httpServer.reset();
 
-        Class ADotAKlass = null;
+        Class<?> ADotAKlass = null;
         try {
             ADotAKlass = loader.loadClass("a.A");
         } catch (ClassNotFoundException cnfe) {