openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1621935 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/OwbParametrizedTypeImpl.java config/OwbWildcardTypeImpl.java util/GenericsUtil.java
Date Tue, 02 Sep 2014 07:07:32 GMT
Author: arne
Date: Tue Sep  2 07:07:32 2014
New Revision: 1621935

URL: http://svn.apache.org/r1621935
Log:
OWB-946: Fixed ParameterizedTypesInjectionToParameterizedWithWildcardTest

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbWildcardTypeImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java?rev=1621935&r1=1621934&r2=1621935&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.java
Tue Sep  2 07:07:32 2014
@@ -116,7 +116,14 @@ public class OwbParametrizedTypeImpl imp
             int length = actualTypes.length;
             for(int i=0;i<length;i++)
             {
-                buffer.append(actualTypes[i].toString());
+                if (actualTypes[i] instanceof Class)
+                {
+                    buffer.append(((Class<?>)actualTypes[i]).getSimpleName());
+                }
+                else
+                {
+                    buffer.append(actualTypes[i].toString());
+                }
                 if(i != actualTypes.length-1)
                 {
                     buffer.append(",");

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbWildcardTypeImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbWildcardTypeImpl.java?rev=1621935&r1=1621934&r2=1621935&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbWildcardTypeImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbWildcardTypeImpl.java
Tue Sep  2 07:07:32 2014
@@ -62,7 +62,15 @@ public class OwbWildcardTypeImpl impleme
                 {
                     buffer.append(',');
                 }
-                buffer.append(' ').append(upperBound);
+                buffer.append(' ');
+                if (upperBound instanceof Class)
+                {
+                    buffer.append(((Class<?>)upperBound).getSimpleName());
+                }
+                else
+                {
+                    buffer.append(upperBound);
+                }
             }
         }
         if (lowerBounds.length > 0)
@@ -79,7 +87,15 @@ public class OwbWildcardTypeImpl impleme
                 {
                     buffer.append(',');
                 }
-                buffer.append(' ').append(lowerBound);
+                buffer.append(' ');
+                if (lowerBound instanceof Class)
+                {
+                    buffer.append(((Class<?>)lowerBound).getSimpleName());
+                }
+                else
+                {
+                    buffer.append(lowerBound);
+                }
             }
         }
         return buffer.toString();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java?rev=1621935&r1=1621934&r2=1621935&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
Tue Sep  2 07:07:32 2014
@@ -336,28 +336,16 @@ public final class GenericsUtil
 
     private static boolean isAssignableFrom(boolean isDelegate, WildcardType injectionPointType,
Type beanType)
     {
+        if (beanType instanceof TypeVariable)
+        {
+            return isAssignableFrom(isDelegate, injectionPointType, (TypeVariable<?>)beanType);
+        }
         for (Type bounds: injectionPointType.getLowerBounds())
         {
             if (!isAssignableFrom(isDelegate, beanType, bounds))
             {
                 return false;
             }
-            /*
-            Set<Type> beanTypeClosure = getTypeClosure(beanType);
-            boolean isAssignable = false;
-            for (Type beanSupertype: beanTypeClosure)
-            {
-                if (isAssignableFrom(isDelegate, beanSupertype, bounds))
-                {
-                    isAssignable = true;
-                    break;
-                }
-            }
-            if (!isAssignable)
-            { 
-                return false;
-            }
-            */
         }
         for (Type bounds: injectionPointType.getUpperBounds())
         {
@@ -383,6 +371,34 @@ public final class GenericsUtil
     }
     
     /**
+     * CDI 1.1 Spec. 5.2.4, third bullet point
+     */
+    private static boolean isAssignableFrom(boolean isDelegate, WildcardType injectionPointType,
TypeVariable<?> beanType)
+    {
+        for (Type upperBound: injectionPointType.getUpperBounds())
+        {
+            for (Type bound: beanType.getBounds())
+            {
+                if (!isAssignableFrom(isDelegate, upperBound, bound) && !isAssignableFrom(isDelegate,
bound, upperBound))
+                {
+                    return false;
+                }
+            }
+        }
+        for (Type lowerBound: injectionPointType.getLowerBounds())
+        {
+            for (Type bound: beanType.getBounds())
+            {
+                if (!isAssignableFrom(isDelegate, bound, lowerBound))
+                {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+    
+    /**
      * @return <tt>true</tt>, if the specified type declaration contains an unresolved
type variable.
      */
     public static boolean containsTypeVariable(Type type)



Mime
View raw message