Hi.

My name is Denis. I am an openjdk developer at Red Hat.
This bug:
https://bugzilla.redhat.com/show_bug.cgi?id=706066
was filed a few days ago and it shows that discovery
is not buildable with openjdk6's javac. I found a fix
for this (which you can find on the bug comments) but
such compiler changes are dangerous and we would like
to avoid them.

That's why I made the attached patch. It works around the
compilation failures by explicitly specifying the
type parameters. It would be wonderful if you could
commit it for me.

Any comments are much appreciated.

Regards,
Denis.
Index: src/java/org/apache/commons/discovery/tools/Service.java
===================================================================
--- src/java/org/apache/commons/discovery/tools/Service.java	(revision 1130252)
+++ src/java/org/apache/commons/discovery/tools/Service.java	(working copy)
@@ -63,7 +63,7 @@
      * @return Enumeration of class instances ({@code S})
      */
     public static <T, S extends T> Enumeration<S> providers(Class<T> spiClass) {
-        return providers(new SPInterface<T>(spiClass), null);
+        return Service.<T, S>providers(new SPInterface<T>(spiClass), null);
     }
 
     /**
Index: src/java/org/apache/commons/discovery/tools/DiscoverClass.java
===================================================================
--- src/java/org/apache/commons/discovery/tools/DiscoverClass.java	(revision 1130252)
+++ src/java/org/apache/commons/discovery/tools/DiscoverClass.java	(working copy)
@@ -185,10 +185,10 @@
      *            the resulting class does not implement (or extend) the SPI.
      */
     public <T, S extends T> Class<S> find(Class<T> spiClass) throws DiscoveryException {
-        return find(getClassLoaders(spiClass),
-                    new SPInterface<T>(spiClass),
-                    nullProperties,
-                    (DefaultClassHolder<T>) null);
+        return DiscoverClass.<T, S>find(getClassLoaders(spiClass),
+                                        new SPInterface<T>(spiClass),
+                                        nullProperties,
+                                        (DefaultClassHolder<T>) null);
     }
 
     /**
@@ -204,10 +204,10 @@
      *            the resulting class does not implement (or extend) the SPI.
      */
     public <T, S extends T> Class<S> find(Class<T> spiClass, Properties properties) throws DiscoveryException {
-        return find(getClassLoaders(spiClass),
-                    new SPInterface<T>(spiClass),
-                    new PropertiesHolder(properties),
-                    (DefaultClassHolder<T>) null);
+        return DiscoverClass.<T, S>find(getClassLoaders(spiClass),
+                                        new SPInterface<T>(spiClass),
+                                        new PropertiesHolder(properties),
+                                        (DefaultClassHolder<T>) null);
     }
 
     /**
@@ -223,10 +223,10 @@
      *            the resulting class does not implement (or extend) the SPI.
      */
     public <T, S extends T> Class<S> find(Class<T> spiClass, String defaultImpl) throws DiscoveryException {
-        return find(getClassLoaders(spiClass),
-                    new SPInterface<T>(spiClass),
-                    nullProperties,
-                    new DefaultClassHolder<T>(defaultImpl));
+        return DiscoverClass.<T, S>find(getClassLoaders(spiClass),
+                                        new SPInterface<T>(spiClass),
+                                        nullProperties,
+                                        new DefaultClassHolder<T>(defaultImpl));
     }
 
     /**
@@ -244,10 +244,10 @@
      */
     public <T, S extends T> Class<S> find(Class<T> spiClass, Properties properties, String defaultImpl)
             throws DiscoveryException {
-        return find(getClassLoaders(spiClass),
-                    new SPInterface<T>(spiClass),
-                    new PropertiesHolder(properties),
-                    new DefaultClassHolder<T>(defaultImpl));
+        return DiscoverClass.<T, S>find(getClassLoaders(spiClass),
+                                        new SPInterface<T>(spiClass),
+                                        new PropertiesHolder(properties),
+                                        new DefaultClassHolder<T>(defaultImpl));
     }
 
     /**
@@ -265,10 +265,10 @@
      */
     public <T, S extends T> Class<S> find(Class<T> spiClass, String propertiesFileName, String defaultImpl)
             throws DiscoveryException {
-        return find(getClassLoaders(spiClass),
-                    new SPInterface<T>(spiClass),
-                    new PropertiesHolder(propertiesFileName),
-                    new DefaultClassHolder<T>(defaultImpl));
+        return DiscoverClass.<T, S>find(getClassLoaders(spiClass),
+                                        new SPInterface<T>(spiClass),
+                                        new PropertiesHolder(propertiesFileName),
+                                        new DefaultClassHolder<T>(defaultImpl));
     }
 
     /**
@@ -517,7 +517,7 @@
                IllegalAccessException,
                NoSuchMethodException,
                InvocationTargetException {
-        return spi.newInstance(find(loaders, spi, properties, defaultImpl));
+        return spi.newInstance(DiscoverClass.<T, T>find(loaders, spi, properties, defaultImpl));
     }
 
     /**
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to