8035487: Fix raw and unchecked lint warnings in javax.imageio.spi
authorhenryjen
Fri, 21 Feb 2014 15:28:39 -0800
changeset 23313 f100f0d49e0b
parent 23312 4711f66e7d5c
child 23314 8e5e3abbbd12
8035487: Fix raw and unchecked lint warnings in javax.imageio.spi Reviewed-by: darcy, prr
jdk/src/share/classes/javax/imageio/ImageReader.java
jdk/src/share/classes/javax/imageio/ImageWriter.java
jdk/src/share/classes/javax/imageio/spi/DigraphNode.java
jdk/src/share/classes/javax/imageio/spi/IIORegistry.java
jdk/src/share/classes/javax/imageio/spi/ImageReaderSpi.java
jdk/src/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java
jdk/src/share/classes/javax/imageio/spi/ImageWriterSpi.java
jdk/src/share/classes/javax/imageio/spi/PartiallyOrderedSet.java
jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java
--- a/jdk/src/share/classes/javax/imageio/ImageReader.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/ImageReader.java	Fri Feb 21 15:28:39 2014 -0800
@@ -291,7 +291,7 @@
         if (input != null) {
             boolean found = false;
             if (originatingProvider != null) {
-                Class[] classes = originatingProvider.getInputTypes();
+                Class<?>[] classes = originatingProvider.getInputTypes();
                 for (int i = 0; i < classes.length; i++) {
                     if (classes[i].isInstance(input)) {
                         found = true;
--- a/jdk/src/share/classes/javax/imageio/ImageWriter.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/ImageWriter.java	Fri Feb 21 15:28:39 2014 -0800
@@ -205,7 +205,7 @@
         if (output != null) {
             ImageWriterSpi provider = getOriginatingProvider();
             if (provider != null) {
-                Class[] classes = provider.getOutputTypes();
+                Class<?>[] classes = provider.getOutputTypes();
                 boolean found = false;
                 for (int i = 0; i < classes.length; i++) {
                     if (classes[i].isInstance(output)) {
--- a/jdk/src/share/classes/javax/imageio/spi/DigraphNode.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/spi/DigraphNode.java	Fri Feb 21 15:28:39 2014 -0800
@@ -39,17 +39,17 @@
  * the current node) may be queried.
  *
  */
-class DigraphNode implements Cloneable, Serializable {
+class DigraphNode<E> implements Cloneable, Serializable {
     private static final long serialVersionUID = 5308261378582246841L;
 
     /** The data associated with this node. */
-    protected Object data;
+    protected E data;
 
     /**
      * A <code>Set</code> of neighboring nodes pointed to by this
      * node.
      */
-    protected Set outNodes = new HashSet();
+    protected Set<DigraphNode<E>> outNodes = new HashSet<>();
 
     /** The in-degree of the node. */
     protected int inDegree = 0;
@@ -58,14 +58,14 @@
      * A <code>Set</code> of neighboring nodes that point to this
      * node.
      */
-    private Set inNodes = new HashSet();
+    private Set<DigraphNode<E>> inNodes = new HashSet<>();
 
-    public DigraphNode(Object data) {
+    public DigraphNode(E data) {
         this.data = data;
     }
 
     /** Returns the <code>Object</code> referenced by this node. */
-    public Object getData() {
+    public E getData() {
         return data;
     }
 
@@ -73,7 +73,7 @@
      * Returns an <code>Iterator</code> containing the nodes pointed
      * to by this node.
      */
-    public Iterator getOutNodes() {
+    public Iterator<DigraphNode<E>> getOutNodes() {
         return outNodes.iterator();
     }
 
@@ -86,7 +86,7 @@
      * @return <code>true</code> if the node was not previously the
      * target of an edge.
      */
-    public boolean addEdge(DigraphNode node) {
+    public boolean addEdge(DigraphNode<E> node) {
         if (outNodes.contains(node)) {
             return false;
         }
@@ -105,7 +105,7 @@
      *
      * @return <code>true</code> if the node is the target of an edge.
      */
-    public boolean hasEdge(DigraphNode node) {
+    public boolean hasEdge(DigraphNode<E> node) {
         return outNodes.contains(node);
     }
 
@@ -116,7 +116,7 @@
      * @return <code>true</code> if the node was previously the target
      * of an edge.
      */
-    public boolean removeEdge(DigraphNode node) {
+    public boolean removeEdge(DigraphNode<E> node) {
         if (!outNodes.contains(node)) {
             return false;
         }
@@ -132,15 +132,17 @@
      * appropriately.
      */
     public void dispose() {
-        Object[] inNodesArray = inNodes.toArray();
+        @SuppressWarnings("unchecked")
+        DigraphNode<E>[] inNodesArray = (DigraphNode<E>[])inNodes.toArray();
         for(int i=0; i<inNodesArray.length; i++) {
-            DigraphNode node = (DigraphNode) inNodesArray[i];
+            DigraphNode<E> node = inNodesArray[i];
             node.removeEdge(this);
         }
 
-        Object[] outNodesArray = outNodes.toArray();
+        @SuppressWarnings("unchecked")
+        DigraphNode<E>[] outNodesArray = (DigraphNode<E>[])outNodes.toArray();
         for(int i=0; i<outNodesArray.length; i++) {
-            DigraphNode node = (DigraphNode) outNodesArray[i];
+            DigraphNode<E> node = outNodesArray[i];
             removeEdge(node);
         }
     }
--- a/jdk/src/share/classes/javax/imageio/spi/IIORegistry.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/spi/IIORegistry.java	Fri Feb 21 15:28:39 2014 -0800
@@ -115,7 +115,7 @@
      * A <code>Vector</code> containing the valid IIO registry
      * categories (superinterfaces) to be used in the constructor.
      */
-    private static final Vector initialCategories = new Vector(5);
+    private static final Vector<Class<?>> initialCategories = new Vector<>(5);
 
     static {
         initialCategories.add(ImageReaderSpi.class);
@@ -198,9 +198,10 @@
 
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
 
-        Iterator categories = getCategories();
+        Iterator<Class<?>> categories = getCategories();
         while (categories.hasNext()) {
-            Class<IIOServiceProvider> c = (Class)categories.next();
+            @SuppressWarnings("unchecked")
+            Class<IIOServiceProvider> c = (Class<IIOServiceProvider>)categories.next();
             Iterator<IIOServiceProvider> riter =
                     ServiceLoader.load(c, loader).iterator();
             while (riter.hasNext()) {
@@ -234,12 +235,13 @@
           file read capability is restricted (like the
           applet context case).
          */
-        PrivilegedAction doRegistration =
-            new PrivilegedAction() {
+        PrivilegedAction<Object> doRegistration =
+            new PrivilegedAction<Object>() {
                 public Object run() {
-                    Iterator categories = getCategories();
+                    Iterator<Class<?>> categories = getCategories();
                     while (categories.hasNext()) {
-                        Class<IIOServiceProvider> c = (Class)categories.next();
+                        @SuppressWarnings("unchecked")
+                        Class<IIOServiceProvider> c = (Class<IIOServiceProvider>)categories.next();
                         for (IIOServiceProvider p : ServiceLoader.loadInstalled(c)) {
                             registerServiceProvider(p);
                         }
--- a/jdk/src/share/classes/javax/imageio/spi/ImageReaderSpi.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/spi/ImageReaderSpi.java	Fri Feb 21 15:28:39 2014 -0800
@@ -81,14 +81,14 @@
      * the equivalent array <code>{ ImageInputStream.class }</code>.
      */
     @Deprecated
-    public static final Class[] STANDARD_INPUT_TYPE =
+    public static final Class<?>[] STANDARD_INPUT_TYPE =
         { ImageInputStream.class };
 
     /**
      * An array of <code>Class</code> objects to be returned from
      * <code>getInputTypes</code>, initially <code>null</code>.
      */
-    protected Class[] inputTypes = null;
+    protected Class<?>[] inputTypes = null;
 
     /**
      * An array of strings to be returned from
@@ -101,7 +101,7 @@
      * The <code>Class</code> of the reader, initially
      * <code>null</code>.
      */
-    private Class readerClass = null;
+    private Class<?> readerClass = null;
 
     /**
      * Constructs a blank <code>ImageReaderSpi</code>.  It is up to
@@ -197,7 +197,7 @@
                           String[] suffixes,
                           String[] MIMETypes,
                           String readerClassName,
-                          Class[] inputTypes,
+                          Class<?>[] inputTypes,
                           String[] writerSpiNames,
                           boolean supportsStandardStreamMetadataFormat,
                           String nativeStreamMetadataFormatName,
@@ -252,9 +252,9 @@
      * returned.
      *
      * @return a non-<code>null</code> array of
-     * <code>Class</code>objects of length at least 1.
+     * <code>Class</code> objects of length at least 1.
      */
-    public Class[] getInputTypes() {
+    public Class<?>[] getInputTypes() {
         return inputTypes.clone();
     }
 
--- a/jdk/src/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java	Fri Feb 21 15:28:39 2014 -0800
@@ -587,7 +587,7 @@
             throw new IllegalArgumentException("Unsupported format name");
         }
         try {
-            Class cls = Class.forName(formatClassName, true,
+            Class<?> cls = Class.forName(formatClassName, true,
                                       ClassLoader.getSystemClassLoader());
             Method meth = cls.getMethod("getInstance");
             return (IIOMetadataFormat) meth.invoke(null);
--- a/jdk/src/share/classes/javax/imageio/spi/ImageWriterSpi.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/spi/ImageWriterSpi.java	Fri Feb 21 15:28:39 2014 -0800
@@ -83,14 +83,14 @@
      * the equivalent array <code>{ ImageOutputStream.class }</code>.
      */
     @Deprecated
-    public static final Class[] STANDARD_OUTPUT_TYPE =
+    public static final Class<?>[] STANDARD_OUTPUT_TYPE =
         { ImageOutputStream.class };
 
     /**
      * An array of <code>Class</code> objects to be returned from
      * <code>getOutputTypes</code>, initially <code>null</code>.
      */
-    protected Class[] outputTypes = null;
+    protected Class<?>[] outputTypes = null;
 
     /**
      * An array of strings to be returned from
@@ -103,7 +103,7 @@
      * The <code>Class</code> of the writer, initially
      * <code>null</code>.
      */
-    private Class writerClass = null;
+    private Class<?> writerClass = null;
 
     /**
      * Constructs a blank <code>ImageWriterSpi</code>.  It is up to
@@ -198,7 +198,7 @@
                           String[] suffixes,
                           String[] MIMETypes,
                           String writerClassName,
-                          Class[] outputTypes,
+                          Class<?>[] outputTypes,
                           String[] readerSpiNames,
                           boolean supportsStandardStreamMetadataFormat,
                           String nativeStreamMetadataFormatName,
@@ -265,9 +265,9 @@
      * returned.
      *
      * @return a non-<code>null</code> array of
-     * <code>Class</code>objects of length at least 1.
+     * <code>Class</code> objects of length at least 1.
      */
-    public Class[] getOutputTypes() {
+    public Class<?>[] getOutputTypes() {
         return outputTypes.clone();
     }
 
--- a/jdk/src/share/classes/javax/imageio/spi/PartiallyOrderedSet.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/spi/PartiallyOrderedSet.java	Fri Feb 21 15:28:39 2014 -0800
@@ -51,17 +51,17 @@
  * supplied by a trusted vendor over those supplied by another.
  *
  */
-class PartiallyOrderedSet extends AbstractSet {
+class PartiallyOrderedSet<E> extends AbstractSet<E> {
 
     // The topological sort (roughly) follows the algorithm described in
     // Horowitz and Sahni, _Fundamentals of Data Structures_ (1976),
     // p. 315.
 
     // Maps Objects to DigraphNodes that contain them
-    private Map poNodes = new HashMap();
+    private Map<E, DigraphNode<E>> poNodes = new HashMap<>();
 
     // The set of Objects
-    private Set nodes = poNodes.keySet();
+    private Set<E> nodes = poNodes.keySet();
 
     /**
      * Constructs a <code>PartiallyOrderedSet</code>.
@@ -81,20 +81,20 @@
      * collection, with an ordering that respects the orderings set
      * by the <code>setOrdering</code> method.
      */
-    public Iterator iterator() {
-        return new PartialOrderIterator(poNodes.values().iterator());
+    public Iterator<E> iterator() {
+        return new PartialOrderIterator<>(poNodes.values().iterator());
     }
 
     /**
      * Adds an <code>Object</code> to this
      * <code>PartiallyOrderedSet</code>.
      */
-    public boolean add(Object o) {
+    public boolean add(E o) {
         if (nodes.contains(o)) {
             return false;
         }
 
-        DigraphNode node = new DigraphNode(o);
+        DigraphNode<E> node = new DigraphNode<>(o);
         poNodes.put(o, node);
         return true;
     }
@@ -104,7 +104,7 @@
      * <code>PartiallyOrderedSet</code>.
      */
     public boolean remove(Object o) {
-        DigraphNode node = (DigraphNode)poNodes.get(o);
+        DigraphNode<E> node = poNodes.get(o);
         if (node == null) {
             return false;
         }
@@ -127,11 +127,9 @@
      * @return <code>true</code> if no prior ordering existed
      * between the nodes, <code>false</code>otherwise.
      */
-    public boolean setOrdering(Object first, Object second) {
-        DigraphNode firstPONode =
-            (DigraphNode)poNodes.get(first);
-        DigraphNode secondPONode =
-            (DigraphNode)poNodes.get(second);
+    public boolean setOrdering(E first, E second) {
+        DigraphNode<E> firstPONode = poNodes.get(first);
+        DigraphNode<E> secondPONode = poNodes.get(second);
 
         secondPONode.removeEdge(firstPONode);
         return firstPONode.addEdge(secondPONode);
@@ -142,11 +140,9 @@
      *
      * @return true if a prior prefence existed between the nodes.
      */
-    public boolean unsetOrdering(Object first, Object second) {
-        DigraphNode firstPONode =
-            (DigraphNode)poNodes.get(first);
-        DigraphNode secondPONode =
-            (DigraphNode)poNodes.get(second);
+    public boolean unsetOrdering(E first, E second) {
+        DigraphNode<E> firstPONode = poNodes.get(first);
+        DigraphNode<E> secondPONode = poNodes.get(second);
 
         return firstPONode.removeEdge(secondPONode) ||
             secondPONode.removeEdge(firstPONode);
@@ -156,25 +152,23 @@
      * Returns <code>true</code> if an ordering exists between two
      * nodes.
      */
-    public boolean hasOrdering(Object preferred, Object other) {
-        DigraphNode preferredPONode =
-            (DigraphNode)poNodes.get(preferred);
-        DigraphNode otherPONode =
-            (DigraphNode)poNodes.get(other);
+    public boolean hasOrdering(E preferred, E other) {
+        DigraphNode<E> preferredPONode = poNodes.get(preferred);
+        DigraphNode<E> otherPONode = poNodes.get(other);
 
         return preferredPONode.hasEdge(otherPONode);
     }
 }
 
-class PartialOrderIterator implements Iterator {
+class PartialOrderIterator<E> implements Iterator<E> {
 
-    LinkedList zeroList = new LinkedList();
-    Map inDegrees = new HashMap(); // DigraphNode -> Integer
+    LinkedList<DigraphNode<E>> zeroList = new LinkedList<>();
+    Map<DigraphNode<E>, Integer> inDegrees = new HashMap<>();
 
-    public PartialOrderIterator(Iterator iter) {
+    public PartialOrderIterator(Iterator<DigraphNode<E>> iter) {
         // Initialize scratch in-degree values, zero list
         while (iter.hasNext()) {
-            DigraphNode node = (DigraphNode)iter.next();
+            DigraphNode<E> node = iter.next();
             int inDegree = node.getInDegree();
             inDegrees.put(node, new Integer(inDegree));
 
@@ -189,14 +183,14 @@
         return !zeroList.isEmpty();
     }
 
-    public Object next() {
-        DigraphNode first = (DigraphNode)zeroList.removeFirst();
+    public E next() {
+        DigraphNode<E> first = zeroList.removeFirst();
 
         // For each out node of the output node, decrement its in-degree
-        Iterator outNodes = first.getOutNodes();
+        Iterator<DigraphNode<E>> outNodes = first.getOutNodes();
         while (outNodes.hasNext()) {
-            DigraphNode node = (DigraphNode)outNodes.next();
-            int inDegree = ((Integer)inDegrees.get(node)).intValue() - 1;
+            DigraphNode<E> node = outNodes.next();
+            int inDegree = inDegrees.get(node).intValue() - 1;
             inDegrees.put(node, new Integer(inDegree));
 
             // If the in-degree has fallen to 0, place the node on the list
--- a/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java	Fri Feb 21 15:28:37 2014 -0800
+++ b/jdk/src/share/classes/javax/imageio/spi/ServiceRegistry.java	Fri Feb 21 15:28:39 2014 -0800
@@ -99,7 +99,7 @@
 public class ServiceRegistry {
 
     // Class -> Registry
-    private Map categoryMap = new HashMap();
+    private Map<Class<?>, SubRegistry> categoryMap = new HashMap<>();
 
     /**
      * Constructs a <code>ServiceRegistry</code> instance with a
@@ -117,7 +117,7 @@
             throw new IllegalArgumentException("categories == null!");
         }
         while (categories.hasNext()) {
-            Class category = (Class)categories.next();
+            Class<?> category = categories.next();
             SubRegistry reg = new SubRegistry(this, category);
             categoryMap.put(category, reg);
         }
@@ -208,7 +208,7 @@
      * <code>Class</code>objects.
      */
     public Iterator<Class<?>> getCategories() {
-        Set keySet = categoryMap.keySet();
+        Set<Class<?>> keySet = categoryMap.keySet();
         return keySet.iterator();
     }
 
@@ -216,13 +216,13 @@
      * Returns an Iterator containing the subregistries to which the
      * provider belongs.
      */
-    private Iterator getSubRegistries(Object provider) {
-        List l = new ArrayList();
-        Iterator iter = categoryMap.keySet().iterator();
+    private Iterator<SubRegistry> getSubRegistries(Object provider) {
+        List<SubRegistry> l = new ArrayList<>();
+        Iterator<Class<?>> iter = categoryMap.keySet().iterator();
         while (iter.hasNext()) {
-            Class c = (Class)iter.next();
+            Class<?> c = iter.next();
             if (c.isAssignableFrom(provider.getClass())) {
-                l.add((SubRegistry)categoryMap.get(c));
+                l.add(categoryMap.get(c));
             }
         }
         return l.iterator();
@@ -259,7 +259,7 @@
         if (provider == null) {
             throw new IllegalArgumentException("provider == null!");
         }
-        SubRegistry reg = (SubRegistry)categoryMap.get(category);
+        SubRegistry reg = categoryMap.get(category);
         if (reg == null) {
             throw new IllegalArgumentException("category unknown!");
         }
@@ -292,9 +292,9 @@
         if (provider == null) {
             throw new IllegalArgumentException("provider == null!");
         }
-        Iterator regs = getSubRegistries(provider);
+        Iterator<SubRegistry> regs = getSubRegistries(provider);
         while (regs.hasNext()) {
-            SubRegistry reg = (SubRegistry)regs.next();
+            SubRegistry reg = regs.next();
             reg.registerServiceProvider(provider);
         }
     }
@@ -362,7 +362,7 @@
         if (provider == null) {
             throw new IllegalArgumentException("provider == null!");
         }
-        SubRegistry reg = (SubRegistry)categoryMap.get(category);
+        SubRegistry reg = categoryMap.get(category);
         if (reg == null) {
             throw new IllegalArgumentException("category unknown!");
         }
@@ -385,9 +385,9 @@
         if (provider == null) {
             throw new IllegalArgumentException("provider == null!");
         }
-        Iterator regs = getSubRegistries(provider);
+        Iterator<SubRegistry> regs = getSubRegistries(provider);
         while (regs.hasNext()) {
-            SubRegistry reg = (SubRegistry)regs.next();
+            SubRegistry reg = regs.next();
             reg.deregisterServiceProvider(provider);
         }
     }
@@ -408,9 +408,9 @@
         if (provider == null) {
             throw new IllegalArgumentException("provider == null!");
         }
-        Iterator regs = getSubRegistries(provider);
+        Iterator<SubRegistry> regs = getSubRegistries(provider);
         while (regs.hasNext()) {
-            SubRegistry reg = (SubRegistry)regs.next();
+            SubRegistry reg = regs.next();
             if (reg.contains(provider)) {
                 return true;
             }
@@ -442,11 +442,13 @@
      */
     public <T> Iterator<T> getServiceProviders(Class<T> category,
                                                boolean useOrdering) {
-        SubRegistry reg = (SubRegistry)categoryMap.get(category);
+        SubRegistry reg = categoryMap.get(category);
         if (reg == null) {
             throw new IllegalArgumentException("category unknown!");
         }
-        return reg.getServiceProviders(useOrdering);
+        @SuppressWarnings("unchecked")
+        Iterator<T> it = (Iterator<T>)reg.getServiceProviders(useOrdering);
+        return it;
     }
 
     /**
@@ -499,12 +501,12 @@
     public <T> Iterator<T> getServiceProviders(Class<T> category,
                                                Filter filter,
                                                boolean useOrdering) {
-        SubRegistry reg = (SubRegistry)categoryMap.get(category);
+        SubRegistry reg = categoryMap.get(category);
         if (reg == null) {
             throw new IllegalArgumentException("category unknown!");
         }
-        Iterator iter = getServiceProviders(category, useOrdering);
-        return new FilterIterator(iter, filter);
+        Iterator<T> iter = getServiceProviders(category, useOrdering);
+        return new FilterIterator<>(iter, filter);
     }
 
     /**
@@ -529,11 +531,11 @@
         if (providerClass == null) {
             throw new IllegalArgumentException("providerClass == null!");
         }
-        Iterator iter = categoryMap.keySet().iterator();
+        Iterator<Class<?>> iter = categoryMap.keySet().iterator();
         while (iter.hasNext()) {
-            Class c = (Class)iter.next();
+            Class<?> c = iter.next();
             if (c.isAssignableFrom(providerClass)) {
-                SubRegistry reg = (SubRegistry)categoryMap.get(c);
+                SubRegistry reg = categoryMap.get(c);
                 T provider = reg.getServiceProviderByClass(providerClass);
                 if (provider != null) {
                     return provider;
@@ -580,7 +582,7 @@
         if (firstProvider == secondProvider) {
             throw new IllegalArgumentException("providers are the same!");
         }
-        SubRegistry reg = (SubRegistry)categoryMap.get(category);
+        SubRegistry reg = categoryMap.get(category);
         if (reg == null) {
             throw new IllegalArgumentException("category unknown!");
         }
@@ -626,7 +628,7 @@
         if (firstProvider == secondProvider) {
             throw new IllegalArgumentException("providers are the same!");
         }
-        SubRegistry reg = (SubRegistry)categoryMap.get(category);
+        SubRegistry reg = categoryMap.get(category);
         if (reg == null) {
             throw new IllegalArgumentException("category unknown!");
         }
@@ -647,7 +649,7 @@
      * corresponding to <code>category</code>.
      */
     public void deregisterAll(Class<?> category) {
-        SubRegistry reg = (SubRegistry)categoryMap.get(category);
+        SubRegistry reg = categoryMap.get(category);
         if (reg == null) {
             throw new IllegalArgumentException("category unknown!");
         }
@@ -659,9 +661,9 @@
      * categories.
      */
     public void deregisterAll() {
-        Iterator iter = categoryMap.values().iterator();
+        Iterator<SubRegistry> iter = categoryMap.values().iterator();
         while (iter.hasNext()) {
-            SubRegistry reg = (SubRegistry)iter.next();
+            SubRegistry reg = iter.next();
             reg.clear();
         }
     }
@@ -690,15 +692,17 @@
 
     ServiceRegistry registry;
 
-    Class category;
+    Class<?> category;
 
     // Provider Objects organized by partial oridering
-    PartiallyOrderedSet poset = new PartiallyOrderedSet();
+    PartiallyOrderedSet<Object> poset = new PartiallyOrderedSet<>();
 
     // Class -> Provider Object of that class
-    Map<Class<?>,Object> map = new HashMap();
+    // No way to express heterogeneous map, we want
+    // Map<Class<T>, T>, where T is ?
+    Map<Class<?>, Object> map = new HashMap<>();
 
-    public SubRegistry(ServiceRegistry registry, Class category) {
+    public SubRegistry(ServiceRegistry registry, Class<?> category) {
         this.registry = registry;
         this.category = category;
     }
@@ -756,7 +760,7 @@
         return poset.unsetOrdering(firstProvider, secondProvider);
     }
 
-    public Iterator getServiceProviders(boolean useOrdering) {
+    public Iterator<Object> getServiceProviders(boolean useOrdering) {
         if (useOrdering) {
             return poset.iterator();
         } else {
@@ -764,12 +768,13 @@
         }
     }
 
+    @SuppressWarnings("unchecked")
     public <T> T getServiceProviderByClass(Class<T> providerClass) {
         return (T)map.get(providerClass);
     }
 
     public void clear() {
-        Iterator iter = map.values().iterator();
+        Iterator<Object> iter = map.values().iterator();
         while (iter.hasNext()) {
             Object provider = iter.next();
             iter.remove();
@@ -794,12 +799,12 @@
  */
 class FilterIterator<T> implements Iterator<T> {
 
-    private Iterator<T> iter;
+    private Iterator<? extends T> iter;
     private ServiceRegistry.Filter filter;
 
     private T next = null;
 
-    public FilterIterator(Iterator<T> iter,
+    public FilterIterator(Iterator<? extends T> iter,
                           ServiceRegistry.Filter filter) {
         this.iter = iter;
         this.filter = filter;