openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1628724 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/creation/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/decorator/ main/java/org/apa...
Date Wed, 01 Oct 2014 14:54:27 GMT
Author: rmannibucau
Date: Wed Oct  1 14:54:27 2014
New Revision: 1628724

URL: http://svn.apache.org/r1628724
Log:
some more generics - producer and managed beans don't share rules :'(

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BaseProducerFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/zoo/GenericsInTheZooTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/GenericClassTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
Wed Oct  1 14:54:27 2014
@@ -59,7 +59,7 @@ public abstract class AbstractBeanBuilde
                     boolean found = false;
                     for (final ProducerMethodBean<?> producer : producerBeans)
                     {
-                        if (GenericsUtil.satisfiesDependency(false, producer.getCreatorMethod().getGenericReturnType(),
param.getBaseType()))
+                        if (GenericsUtil.satisfiesDependency(false, true, producer.getCreatorMethod().getGenericReturnType(),
param.getBaseType()))
                         {
                             found = true;
                             break;
@@ -69,7 +69,7 @@ public abstract class AbstractBeanBuilde
                     {
                         for (final ProducerFieldBean<?> field : producerFields)
                         {
-                            if (GenericsUtil.satisfiesDependency(false, field.getCreatorField().getType(),
param.getBaseType()))
+                            if (GenericsUtil.satisfiesDependency(false, true, field.getCreatorField().getType(),
param.getBaseType()))
                             {
                                 found = true;
                                 break;
@@ -81,7 +81,7 @@ public abstract class AbstractBeanBuilde
                             // see if @Disposes should just be ignored as well - no inheritance
                             for (final AnnotatedMethod<?> producer : ignoredProducers)
                             {
-                                if (GenericsUtil.satisfiesDependency(false, producer.getJavaMember().getGenericReturnType(),
param.getBaseType()))
+                                if (GenericsUtil.satisfiesDependency(false, true, producer.getJavaMember().getGenericReturnType(),
param.getBaseType()))
                                 {
                                     found = true;
                                     break;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BaseProducerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BaseProducerFactory.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BaseProducerFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BaseProducerFactory.java
Wed Oct  1 14:54:27 2014
@@ -102,7 +102,7 @@ public abstract class BaseProducerFactor
                 {
                     if (annotatedParameter.isAnnotationPresent(Disposes.class))
                     {
-                        if (!GenericsUtil.satisfiesDependency(false, producerBaseType, annotatedParameter.getBaseType()))
+                        if (!GenericsUtil.satisfiesDependency(false, true, producerBaseType,
annotatedParameter.getBaseType()))
                         {
                             continue;
                         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Wed Oct  1 14:54:27 2014
@@ -384,7 +384,7 @@ public class BeansDeployer
 
                         if (pt1.getRawType() == pt2.getRawType())
                         {
-                            if (!GenericsUtil.isAssignableFrom(true, pt1, pt2))
+                            if (!GenericsUtil.isAssignableFrom(true, false, pt1, pt2))
                             {
                                 throw new DefinitionException("Generic error matching " +
api + " and " + t);
                             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Wed Oct  1 14:54:27 2014
@@ -55,6 +55,7 @@ import javax.naming.Referenceable;
 import javax.naming.StringRefAddr;
 
 import org.apache.webbeans.component.AbstractOwbBean;
+import org.apache.webbeans.component.AbstractProducerBean;
 import org.apache.webbeans.component.CdiInterceptorBean;
 import org.apache.webbeans.component.DecoratorBean;
 import org.apache.webbeans.component.EnterpriseBeanMarker;
@@ -694,7 +695,7 @@ public class BeanManagerImpl implements 
         if(beanType != null && beanType != Object.class)
         {
             if(!isBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof
NewBean) &&
-               !GenericsUtil.satisfiesDependency(false, beanType, bean.getBeanClass()))
+               !GenericsUtil.satisfiesDependency(false, AbstractProducerBean.class.isInstance(bean),
beanType, bean.getBeanClass()))
             {
                 throw new IllegalArgumentException("Given bean type : " + beanType + " is
not applicable for the bean instance : " + bean);
             }
@@ -872,7 +873,7 @@ public class BeanManagerImpl implements 
         {
             Type beanApiType = itBeanApiTypes.next();
 
-            if(GenericsUtil.satisfiesDependency(false, givenType, beanApiType))
+            if(GenericsUtil.satisfiesDependency(false, false, givenType, beanApiType))
             {
                 return true;
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Wed Oct  1 14:54:27 2014
@@ -21,6 +21,7 @@ package org.apache.webbeans.container;
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractOwbBean;
+import org.apache.webbeans.component.AbstractProducerBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.OwbBean;
@@ -472,7 +473,8 @@ public class InjectionResolver
                 for (Type componentApiType : component.getTypes())
                 {
 
-                    if (GenericsUtil.satisfiesDependency(isDelegate, injectionPointType,
componentApiType))
+                    if (GenericsUtil.satisfiesDependency(isDelegate, AbstractProducerBean.class.isInstance(component),
+                            injectionPointType, componentApiType))
                     {
                         resolvedComponents.add(component);
                         break;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorsManager.java
Wed Oct  1 14:54:27 2014
@@ -222,7 +222,7 @@ public class DecoratorsManager
         boolean ok = false;
         for (Type apiType : apiTypes)
         {
-            if (GenericsUtil.satisfiesDependency(true, decorator.getDelegateType(), apiType))
+            if (GenericsUtil.satisfiesDependency(true, false, decorator.getDelegateType(),
apiType))
             {
                 ok = true;
                 break;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Wed Oct  1 14:54:27 2014
@@ -285,7 +285,7 @@ public final class NotificationManager
         {
             for (Type eventType : eventTypes)
             {
-                if (GenericsUtil.isAssignableFrom(true, observedType, eventType))
+                if (GenericsUtil.isAssignableFrom(true, false, observedType, eventType))
                 {
                     Set<ObserverMethod<?>> observerMethods = observers.get(observedType);
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventProducer.java
Wed Oct  1 14:54:27 2014
@@ -64,7 +64,7 @@ public class EventProducer<T> extends Ab
             {
                 final ParameterizedType arg = ParameterizedType.class.cast(event);
                 final Type[] actualTypeArguments = arg.getActualTypeArguments();
-                if (actualTypeArguments.length > 0 && GenericsUtil.isAssignableFrom(true,
actualTypeArguments[0], type))
+                if (actualTypeArguments.length > 0 && GenericsUtil.isAssignableFrom(true,
false, actualTypeArguments[0], type))
                 {
                     list.add(original);
                 }

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=1628724&r1=1628723&r2=1628724&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
Wed Oct  1 14:54:27 2014
@@ -45,11 +45,11 @@ import org.apache.webbeans.config.OwbWil
  */
 public final class GenericsUtil
 {
-    public static boolean satisfiesDependency(boolean isDelegateOrEvent, Type injectionPointType,
Type beanType)
+    public static boolean satisfiesDependency(boolean isDelegateOrEvent, boolean isProducer,
Type injectionPointType, Type beanType)
     {
         if (beanType instanceof TypeVariable || beanType instanceof WildcardType || beanType
instanceof GenericArrayType)
         {
-            return isAssignableFrom(isDelegateOrEvent, injectionPointType, beanType);
+            return isAssignableFrom(isDelegateOrEvent, isProducer, injectionPointType, beanType);
         }
         else
         {
@@ -58,7 +58,7 @@ public final class GenericsUtil
             
             if  (ClassUtil.isSame(injectionPointRawType, beanRawType))
             {
-                return isAssignableFrom(isDelegateOrEvent, injectionPointType, beanType);
+                return isAssignableFrom(isDelegateOrEvent, isProducer, injectionPointType,
beanType);
             }
         }
 
@@ -68,7 +68,7 @@ public final class GenericsUtil
     /**
      * 5.2.3 and 5.2.4
      */
-    public static boolean isAssignableFrom(boolean isDelegateOrEvent, Type requiredType,
Type beanType)
+    public static boolean isAssignableFrom(boolean isDelegateOrEvent, boolean isProducer,
Type requiredType, Type beanType)
     {
         if (requiredType instanceof Class)
         {
@@ -76,7 +76,7 @@ public final class GenericsUtil
         }
         else if (requiredType instanceof ParameterizedType)
         {
-            return isAssignableFrom(isDelegateOrEvent, (ParameterizedType)requiredType, beanType);
+            return isAssignableFrom(isDelegateOrEvent, isProducer, (ParameterizedType)requiredType,
beanType);
         }
         else if (requiredType instanceof TypeVariable)
         {
@@ -117,7 +117,7 @@ public final class GenericsUtil
         }
         else if (beanType instanceof WildcardType)
         {
-            return isAssignableFrom(isDelegateOrEvent, (Type)injectionPointType, (WildcardType)beanType);
+            return isAssignableFrom(isDelegateOrEvent, false, (Type)injectionPointType, (WildcardType)beanType);
         }
         else
         {
@@ -176,25 +176,21 @@ public final class GenericsUtil
 
     private static boolean isAssignableFrom(boolean isDelegateOrEvent, Class<?> injectionPointType,
GenericArrayType beanType)
     {
-        if (!injectionPointType.isArray())
-        {
-            return false;
-        }
-        return isAssignableFrom(isDelegateOrEvent, injectionPointType.getComponentType(),
beanType.getGenericComponentType());
+        return injectionPointType.isArray() && isAssignableFrom(isDelegateOrEvent,
injectionPointType.getComponentType(), beanType.getGenericComponentType());
     }
     
-    private static boolean isAssignableFrom(boolean isDelegateOrEvent, Type injectionPointType,
WildcardType beanType)
+    private static boolean isAssignableFrom(boolean isDelegateOrEvent, boolean isProducer,
Type injectionPointType, WildcardType beanType)
     {
         for (Type bounds: beanType.getLowerBounds())
         {
-            if (!isAssignableFrom(isDelegateOrEvent, bounds, injectionPointType))
+            if (!isAssignableFrom(isDelegateOrEvent, false, bounds, injectionPointType))
             {
                 return false;
             }
         }
         for (Type bounds: beanType.getUpperBounds())
         {
-            if (isAssignableFrom(isDelegateOrEvent, injectionPointType, bounds))
+            if (isAssignableFrom(isDelegateOrEvent, false, injectionPointType, bounds))
             {
                 return true;
             }
@@ -202,23 +198,23 @@ public final class GenericsUtil
         return false;
     }
 
-    private static boolean isAssignableFrom(boolean isDelegateOrEvent, ParameterizedType
injectionPointType, Type beanType)
+    private static boolean isAssignableFrom(boolean isDelegateOrEvent, boolean isProducer,
ParameterizedType injectionPointType, Type beanType)
     {
         if (beanType instanceof Class)
         {
-            return isAssignableFrom(isDelegateOrEvent, injectionPointType, (Class<?>)beanType);
+            return isAssignableFrom(isDelegateOrEvent, isProducer, injectionPointType, (Class<?>)beanType);
         }
         else if (beanType instanceof TypeVariable)
         {
-            return isAssignableFrom(isDelegateOrEvent, injectionPointType, (TypeVariable<?>)beanType);
+            return isAssignableFrom(isDelegateOrEvent, isProducer, injectionPointType, (TypeVariable<?>)beanType);
         }
         else if (beanType instanceof ParameterizedType)
         {
-            return isAssignableFrom(isDelegateOrEvent, injectionPointType, (ParameterizedType)beanType);
+            return isAssignableFrom(isDelegateOrEvent, isProducer, injectionPointType, (ParameterizedType)beanType);
         }
         else if (beanType instanceof WildcardType)
         {
-            return isAssignableFrom(isDelegateOrEvent, (Type)injectionPointType, (WildcardType)beanType);
+            return isAssignableFrom(isDelegateOrEvent, isProducer, (Type)injectionPointType,
(WildcardType)beanType);
         }
         else if (beanType instanceof GenericArrayType)
         {
@@ -230,7 +226,7 @@ public final class GenericsUtil
         }
     }
 
-    private static boolean isAssignableFrom(boolean isDelegateOrEvent, ParameterizedType
injectionPointType, Class<?> beanType)
+    private static boolean isAssignableFrom(boolean isDelegateOrEvent, boolean isProducer,
ParameterizedType injectionPointType, Class<?> beanType)
     {
         Class<?> rawInjectionPointType = getRawType(injectionPointType);
         if (rawInjectionPointType.equals(beanType))
@@ -241,13 +237,13 @@ public final class GenericsUtil
         {
             return false;
         }
-        if (beanType.getSuperclass() != null && isAssignableFrom(isDelegateOrEvent,
injectionPointType, beanType.getGenericSuperclass()))
+        if (beanType.getSuperclass() != null && isAssignableFrom(isDelegateOrEvent,
isProducer, injectionPointType, beanType.getGenericSuperclass()))
         {
             return true;
         }
         for (Type genericInterface: beanType.getGenericInterfaces())
         {
-            if (isAssignableFrom(isDelegateOrEvent, injectionPointType, genericInterface))
+            if (isAssignableFrom(isDelegateOrEvent, isProducer, injectionPointType, genericInterface))
             {
                 return true;
             }
@@ -255,11 +251,16 @@ public final class GenericsUtil
         return false;
     }
 
-    private static boolean isAssignableFrom(boolean isDelegateOrEvent, ParameterizedType
injectionPointType, TypeVariable<?> beanType)
+    private static boolean isAssignableFrom(boolean isDelegateOrEvent, boolean isProducer,
ParameterizedType injectionPointType, TypeVariable<?> beanType)
     {
-        for (Type bounds: beanType.getBounds())
+        final Type[] types = beanType.getBounds();
+        if (isNotBound(types))
         {
-            if (isAssignableFrom(isDelegateOrEvent, injectionPointType, bounds))
+            return true;
+        }
+        for (final Type bounds: types)
+        {
+            if (isAssignableFrom(isDelegateOrEvent, isProducer, injectionPointType, bounds))
             {
                 return true;
             }
@@ -270,7 +271,7 @@ public final class GenericsUtil
     /**
      * CDI Spec. 5.2.4
      */
-    private static boolean isAssignableFrom(boolean isDelegateOrEvent, ParameterizedType
injectionPointType, ParameterizedType beanType)
+    private static boolean isAssignableFrom(boolean isDelegateOrEvent, boolean isProducer,
ParameterizedType injectionPointType, ParameterizedType beanType)
     {
         if (injectionPointType.getRawType() != beanType.getRawType())
         {
@@ -290,21 +291,30 @@ public final class GenericsUtil
                 (injectionPointTypeArgument instanceof Class || injectionPointTypeArgument
instanceof TypeVariable) &&
                 beanTypeArgument instanceof TypeVariable)
             {
-                for (Type upperBound: ((TypeVariable<?>)beanTypeArgument).getBounds())
+                final Type[] bounds = ((TypeVariable<?>) beanTypeArgument).getBounds();
+                final boolean isNotBound = isNotBound(bounds);
+                if (isNotBound)
+                {
+                    final boolean valid = Object.class == injectionPointTypeArgument
+                            || (TypeVariable.class.isInstance(injectionPointTypeArgument)
&& isNotBound(TypeVariable.class.cast(injectionPointTypeArgument).getBounds()));
+                    if (!valid)
+                    {
+                        return !isProducer;
+                    }
+                }
+                for (final Type upperBound : bounds)
                 {
-                    if (!isAssignableFrom(true, upperBound, injectionPointTypeArgument))
+                    if (!isAssignableFrom(true, false, upperBound, injectionPointTypeArgument))
                     {
                         return false;
                     }
                 }
-
             }
             else if (swapParams && injectionPointTypeArgument instanceof TypeVariable)
             {
                 return false;
             }
-            else if ((!TypeVariable.class.isInstance(beanTypeArgument) || TypeVariable.class.cast(beanTypeArgument).getGenericDeclaration()
!= beanType.getRawType())
-                && !isAssignableFrom(isDelegateOrEvent, injectionPointTypeArgument,
beanTypeArgument))
+            else if (!isAssignableFrom(isDelegateOrEvent, false, injectionPointTypeArgument,
beanTypeArgument))
             {
                 return false;
             }
@@ -312,11 +322,16 @@ public final class GenericsUtil
         return true;
     }
 
+    private static boolean isNotBound(final Type... bounds)
+    {
+        return bounds == null || bounds.length == 0 || (bounds.length == 1 && Object.class
== bounds[0]);
+    }
+
     private static boolean isAssignableFrom(boolean isDelegateOrEvent, TypeVariable<?>
injectionPointType, Type beanType)
     {
         for (Type bounds: injectionPointType.getBounds())
         {
-            if (!isAssignableFrom(isDelegateOrEvent, bounds, beanType))
+            if (!isAssignableFrom(isDelegateOrEvent, false, bounds, beanType))
             {
                 return false;
             }
@@ -335,9 +350,9 @@ public final class GenericsUtil
         }
         if (ParameterizedType.class.isInstance(genericComponentType))
         {
-            return isAssignableFrom(isDelegateOrEvent, ParameterizedType.class.cast(genericComponentType).getRawType(),
componentType);
+            return isAssignableFrom(isDelegateOrEvent, false, ParameterizedType.class.cast(genericComponentType).getRawType(),
componentType);
         }
-        return isAssignableFrom(isDelegateOrEvent, genericComponentType, componentType);
+        return isAssignableFrom(isDelegateOrEvent, false, genericComponentType, componentType);
     }
 
     private static boolean isAssignableFrom(boolean isDelegateOrEvent, WildcardType injectionPointType,
Type beanType)
@@ -348,7 +363,7 @@ public final class GenericsUtil
         }
         for (Type bounds: injectionPointType.getLowerBounds())
         {
-            if (!isAssignableFrom(isDelegateOrEvent, beanType, bounds))
+            if (!isAssignableFrom(isDelegateOrEvent, false, beanType, bounds))
             {
                 return false;
             }
@@ -359,7 +374,7 @@ public final class GenericsUtil
             boolean isAssignable = false;
             for (Type beanSupertype: beanTypeClosure)
             {
-                if (isAssignableFrom(isDelegateOrEvent, bounds, beanSupertype)
+                if (isAssignableFrom(isDelegateOrEvent, false, bounds, beanSupertype)
                     || (Class.class.isInstance(bounds)
                         && ParameterizedType.class.isInstance(beanSupertype)
                         && bounds == ParameterizedType.class.cast(beanSupertype).getRawType()))
@@ -385,7 +400,7 @@ public final class GenericsUtil
         {
             for (Type bound: beanType.getBounds())
             {
-                if (!isAssignableFrom(isDelegateOrEvent, upperBound, bound) && !isAssignableFrom(isDelegateOrEvent,
bound, upperBound))
+                if (!isAssignableFrom(isDelegateOrEvent, false, upperBound, bound) &&
!isAssignableFrom(isDelegateOrEvent, false, bound, upperBound))
                 {
                     return false;
                 }
@@ -395,7 +410,7 @@ public final class GenericsUtil
         {
             for (Type bound: beanType.getBounds())
             {
-                if (!isAssignableFrom(isDelegateOrEvent, bound, lowerBound))
+                if (!isAssignableFrom(isDelegateOrEvent, false, bound, lowerBound))
                 {
                     return false;
                 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Wed Oct  1 14:54:27 2014
@@ -1645,7 +1645,7 @@ public final class WebBeansUtil
                     rawType.equals(Interceptor.class))
                 {
                     Type[] types = ClassUtil.getActualTypeArguments(injectionPoint.getType());
-                    if (types.length != 1 || !GenericsUtil.isAssignableFrom(false, bean.getBeanClass(),
types[0]))
+                    if (types.length != 1 || !GenericsUtil.isAssignableFrom(false, AbstractProducerBean.class.isInstance(bean),
bean.getBeanClass(), types[0]))
                     {
                         throw new DefinitionException("injected bean parameter must be "
+ rawType);
                     }
@@ -1859,7 +1859,7 @@ public final class WebBeansUtil
                     final Class<?> beanClass = AbstractOwbBean.class.isInstance(injectionPointBean)
?
                             AbstractOwbBean.class.cast(injectionPointBean).getReturnType()
: injectionPointBean.getBeanClass();
                     final Type beanType = pt.getActualTypeArguments()[0];
-                    if (!GenericsUtil.isAssignableFrom(false, beanClass, beanType))
+                    if (!GenericsUtil.isAssignableFrom(false, AbstractProducerBean.class.isInstance(bean),
beanClass, beanType))
                     {
                         throw new DefinitionException("@Inject Bean<X> can only be
done in X, found " + beanType + " and " + beanClass);
                     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/zoo/GenericsInTheZooTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/zoo/GenericsInTheZooTest.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/zoo/GenericsInTheZooTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/zoo/GenericsInTheZooTest.java
Wed Oct  1 14:54:27 2014
@@ -18,11 +18,13 @@
  */
 package org.apache.webbeans.test.injection.generics.zoo;
 
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.junit.Assert;
 import org.junit.Test;
 
 import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.DeploymentException;
 import javax.inject.Inject;
 
 /**
@@ -62,7 +64,7 @@ public class GenericsInTheZooTest extend
         }
     }
 
-    @Test
+    @Test(expected = WebBeansConfigurationException.class) // yes it sucks but producers
and managed beans doesn't have same rules
     public void testGenericProducer() throws Exception
     {
         // create the stables via a single producer method

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/GenericClassTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/GenericClassTest.java?rev=1628724&r1=1628723&r2=1628724&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/GenericClassTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/GenericClassTest.java
Wed Oct  1 14:54:27 2014
@@ -44,10 +44,10 @@ public class GenericClassTest
         Field check22Bound = Dao.class.getField("check22WithBound");
         Field check4 = WithTypeVariable.class.getField("check4");
 
-        Assert.assertFalse(GenericsUtil.satisfiesDependency(false, raw.getGenericType(),
t.getGenericType()));
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, check4.getGenericType(),
t.getGenericType()));
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, check22.getGenericType(),
t.getGenericType()));
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, check22Bound.getGenericType(),
t.getGenericType()));
+        Assert.assertFalse(GenericsUtil.satisfiesDependency(false, false, raw.getGenericType(),
t.getGenericType()));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, check4.getGenericType(),
t.getGenericType()));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, check22.getGenericType(),
t.getGenericType()));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, check22Bound.getGenericType(),
t.getGenericType()));
     }
     
     @Test
@@ -59,8 +59,8 @@ public class GenericClassTest
         Field f4 = UserDao.class.getField("field4");
 
 
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, f3.getGenericType(), f1.getGenericType()));
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, f4.getGenericType(), f1.getGenericType()));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, f3.getGenericType(),
f1.getGenericType()));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, f4.getGenericType(),
f1.getGenericType()));
     }
 
     @Test
@@ -74,8 +74,8 @@ public class GenericClassTest
         Type pigStableType = this.getClass().getDeclaredField("pigStable").getType().getGenericSuperclass();
         Type horseStableType = this.getClass().getDeclaredField("horseStable").getType().getGenericSuperclass();
 
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, horseStableType, parameterizedHorseStableType));
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, parameterizedPigStableType,
pigStableType));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, horseStableType,
parameterizedHorseStableType));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, parameterizedPigStableType,
pigStableType));
     }
     // fields for {@link #testStable}
     private Stable<Horse> parameterizedHorseStable;
@@ -91,8 +91,8 @@ public class GenericClassTest
         Type parameterizedHorseStableType = this.getClass().getDeclaredField("parameterizedHorseStable").getGenericType();
         Type stableProducerMethodType = this.getClass().getDeclaredMethod("stableProducer").getGenericReturnType();
 
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, parameterizedPigStableType,
stableProducerMethodType));
-        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, parameterizedHorseStableType,
stableProducerMethodType));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, parameterizedPigStableType,
stableProducerMethodType));
+        Assert.assertTrue(GenericsUtil.satisfiesDependency(false, false, parameterizedHorseStableType,
stableProducerMethodType));
     }
     // method and field for {@link #testGenericProducerType}
     private <T> Stable<T> stableProducer()



Mime
View raw message