aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1734053 - /aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceProxyGenerator.java
Date Tue, 08 Mar 2016 10:58:09 GMT
Author: gnodet
Date: Tue Mar  8 10:58:09 2016
New Revision: 1734053

URL: http://svn.apache.org/viewvc?rev=1734053&view=rev
Log:
[ARIES-1342] Aries Proxy Impl fails to proxy a service with covariant type hierarchy in Java
8

Modified:
    aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceProxyGenerator.java

Modified: aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceProxyGenerator.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceProxyGenerator.java?rev=1734053&r1=1734052&r2=1734053&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceProxyGenerator.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/main/java/org/apache/aries/proxy/impl/interfaces/InterfaceProxyGenerator.java
Tue Mar  8 10:58:09 2016
@@ -115,7 +115,18 @@ public final class InterfaceProxyGenerat
   private static SortedSet<Class<?>> createSet(Collection<Class<?>>
ifaces) {
     SortedSet<Class<?>> classes = new TreeSet<Class<?>>(new Comparator<Class<?>>()
{
       public int compare(Class<?> object1, Class<?> object2) {
-        return object1.getName().compareTo(object2.getName());
+        if (object1.getName().equals(object2.getName())) {
+          return 0;
+        } else if (object1.isAssignableFrom(object2)) {
+          // first class is parent of second, it occurs earlier in type hierarchy
+          return -1;
+        } else if (object2.isAssignableFrom(object1)) {
+          // second class is subclass of first one, it occurs later in hierarchy
+          return 1;
+        }
+        // types have separate inheritance trees, so it doesn't mater which one is first
or second,
+        // however we can't mark them as equal cause one of them will be removed
+        return 1;
       }
     });
     for(Class<?> c : ifaces) {



Mime
View raw message