openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1502035 [1/2] - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/sr...
Date Wed, 10 Jul 2013 22:48:59 GMT
Author: arne
Date: Wed Jul 10 22:48:58 2013
New Revision: 1502035

URL: http://svn.apache.org/r1502035
Log:
OWB-878: Re-implemented generic handling

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/inject/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/inject/generic/
      - copied from r1502033, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Bar.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BarVetoExtension.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Baz.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BazSubclass.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Foo.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/GenericBeanTest.java
      - copied, changed from r1502033, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/GenericBeanTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/GenericFactory.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/GenericQualifier.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/GenericsTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/GenericsUtilTest.java
Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeanTypeSetResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/DecoratorResolverRules.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/inject/generic/GenericBeanTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/generic/
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OwbParametrizedTypeImpl.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/ObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/GenericDecoratorTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/beans/MethodTypeProduces1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/clazz/ClazzTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/parametrized/GenericClassTest.java
    openwebbeans/trunk/webbeans-jsf/src/main/java/org/apache/webbeans/jsf/plugin/OpenWebBeansJsfPlugin.java
    openwebbeans/trunk/webbeans-jsf12/src/main/java/org/apache/webbeans/jsf12/plugin/OpenWebBeansJsfPlugin.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java Wed Jul 10 22:48:58 2013
@@ -67,7 +67,7 @@ public class AbstractProducerBean<T> ext
 
     @Override
     public Class<T> getReturnType()
-    {
+    { 
         return returnType;
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java Wed Jul 10 22:48:58 2013
@@ -24,7 +24,6 @@ import java.lang.reflect.Field;
 import javax.enterprise.context.spi.CreationalContext;
 
 import org.apache.webbeans.component.spi.ProducerFactory;
-import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -108,7 +107,7 @@ public class ProducerFieldBean<T> extend
                               " with passivating scope @%s" +
                               " must be Serializable";
         getWebBeansContext().getWebBeansUtil().checkSerializableScopeType(getScope(),
-                ClassUtil.isClassAssignable(Serializable.class, getReturnType()), errorMessage, producerField.getName(), 
+                getReturnType() instanceof Serializable, errorMessage, producerField.getName(), 
                 getBeanClass().getName(), getScope().getName());
     }
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java Wed Jul 10 22:48:58 2013
@@ -25,7 +25,6 @@ import javax.enterprise.context.spi.Crea
 
 import org.apache.webbeans.component.creation.MethodProducerFactory;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -150,7 +149,7 @@ public class ProducerMethodBean<T> exten
                               " with passivating scope @%s" +
                               " must be Serializable";
         getWebBeansContext().getWebBeansUtil().checkSerializableScopeType(getScope(),
-                ClassUtil.isClassAssignable(Serializable.class, getReturnType()), errorMessage, creatorMethod.getName(), getBeanClass().getName(),
+                getReturnType() instanceof Serializable, errorMessage, creatorMethod.getName(), getBeanClass().getName(),
                 getScope().getName());
 
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java Wed Jul 10 22:48:58 2013
@@ -29,11 +29,12 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
+
+import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -46,13 +47,12 @@ import org.apache.webbeans.component.Bea
 import org.apache.webbeans.component.DecoratorBean;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.OWBLogConst;
-import org.apache.webbeans.config.OwbParametrizedTypeImpl;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
-
+import org.apache.webbeans.util.GenericsUtil;
 
 /**
  * Bean builder for {@link org.apache.webbeans.component.InterceptorBean}s.
@@ -165,57 +165,15 @@ public class DecoratorBeanBuilder<T>
 
     private void defineDecoratedTypes()
     {
-        // remove them first to avoid to loop over them
-        decoratedTypes.remove(Object.class);
-        decoratedTypes.remove(java.io.Serializable.class); /* 8.1 */
-
-        Type beanClass = annotatedType.getJavaClass();
-        do
-        {
-            final Class<?> clazz = ClassUtil.getClass(beanClass);
-            final Type toRemove;
-            if (ClassUtil.isDefinitionContainsTypeVariables(beanClass))
-            {
-                final OwbParametrizedTypeImpl pt = new OwbParametrizedTypeImpl(clazz.getDeclaringClass(), clazz);
-                final TypeVariable<?>[] tvs = clazz.getTypeParameters();
-                for(TypeVariable<?> tv : tvs)
-                {
-                    pt.addTypeArgument(tv);
-                }
-                toRemove = pt;
-                //X TODO generic support setDecoratorGenericType(pt);
-            }
-            else
-            {
-                toRemove = beanClass;
-                //X TODO generic support setDecoratorGenericType(beanClass);
-            }
-
-            final Iterator<Type> iterator = decoratedTypes.iterator();
-            while (iterator.hasNext())
-            {
-                final Type next = iterator.next();
-
-                // if raw class is the same and is assignable (generics handling)
-                if (ClassUtil.getClass(next) == clazz && ClassUtil.isAssignable(toRemove, next))
-                {
-                    iterator.remove();
-                }
-            }
-
-            beanClass = clazz.getGenericSuperclass();
-        } while (beanClass != Object.class);
-
-
+        decoratedTypes.remove(Serializable.class); /* 8.1 */
         for (Iterator<Type> i = decoratedTypes.iterator(); i.hasNext(); )
         {
             Type t = i.next();
-            if (t instanceof Class<?> && ignoredDecoratorInterfaces.contains(((Class) t).getName()))
+            if (!ClassUtil.getClass(t).isInterface() || (t instanceof Class<?> && ignoredDecoratorInterfaces.contains(((Class) t).getName())))
             {
                 i.remove();
             }
         }
-
     }
 
     private void defineDelegate(Set<InjectionPoint> injectionPoints)
@@ -258,7 +216,7 @@ public class DecoratorBeanBuilder<T>
             }
         }
 
-        delegateType = ipFound.getType();
+        delegateType = GenericsUtil.resolveType(ipFound.getType(), annotatedType.getJavaClass(), ipFound.getMember());
         delegateQualifiers = ipFound.getQualifiers();
 
         for (Type decType : decoratedTypes)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java Wed Jul 10 22:48:58 2013
@@ -317,11 +317,11 @@ public abstract class InterceptorBeanBui
         {
             if (clazz == null)
             {
-                clazz = annotatedMethod.getDeclaringType().getJavaClass();
+                clazz = annotatedMethod.getJavaMember().getDeclaringClass();
             }
 
             // check for same class -> Exception
-            if (alreadyDefined.getDeclaringType().getJavaClass() ==  clazz)
+            if (alreadyDefined.getJavaMember().getDeclaringClass() == clazz)
             {
                 throw new WebBeansConfigurationException("Only one Interceptor of a certain type is allowed per class, but multiple found in class "
                         + annotatedMethod.getDeclaringType().getJavaClass().getName()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java Wed Jul 10 22:48:58 2013
@@ -41,7 +41,7 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.portable.ProducerMethodProducer;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.GenericsUtil;
 
 public class MethodProducerFactory<P> implements ProducerFactory<P>
 {
@@ -98,7 +98,7 @@ public class MethodProducerFactory<P> im
                 {
                     if (annotatedParameter.isAnnotationPresent(Disposes.class))
                     {
-                        if (!ClassUtil.isAssignable(annotatedParameter.getBaseType(), producerMethod.getBaseType()))
+                        if (!GenericsUtil.satisfiesDependency(producerMethod.getBaseType(), annotatedParameter.getBaseType()))
                         {
                             continue;
                         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java Wed Jul 10 22:48:58 2013
@@ -77,7 +77,7 @@ public class ProducerFieldBeansBuilder<T
         Set<AnnotatedField<? super T>> annotatedFields = annotatedType.getFields();        
         for(AnnotatedField<? super T> annotatedField: annotatedFields)
         {
-            if(annotatedField.isAnnotationPresent(Produces.class) && annotatedField.getDeclaringType().getJavaClass().equals(annotatedType.getJavaClass()))
+            if(annotatedField.isAnnotationPresent(Produces.class) && annotatedField.getJavaMember().getDeclaringClass().equals(annotatedType.getJavaClass()))
             {
                 Type genericType = annotatedField.getBaseType();
                 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java Wed Jul 10 22:48:58 2013
@@ -26,7 +26,7 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.GenericsUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 import javax.enterprise.event.Observes;
@@ -77,7 +77,7 @@ public class ProducerMethodBeansBuilder<
         {
             boolean enterprise = EnterpriseBeanMarker.class.isInstance(bean);
             if(annotatedMethod.isAnnotationPresent(Produces.class) &&
-                (annotatedMethod.getDeclaringType().getJavaClass().equals(annotatedType.getJavaClass())
+                (annotatedMethod.getJavaMember().getDeclaringClass().equals(annotatedType.getJavaClass())
                 || (enterprise && annotatedType.getJavaClass().isAssignableFrom(annotatedType.getJavaClass()))))
             {
                 checkProducerMethodForDeployment(annotatedMethod);
@@ -126,7 +126,7 @@ public class ProducerMethodBeansBuilder<
                     boolean found = false;
                     for (final ProducerMethodBean<?> producer : producerBeans)
                     {
-                        if (ClassUtil.isAssignable(param.getBaseType(), producer.getCreatorMethod().getGenericReturnType()))
+                        if (GenericsUtil.satisfiesDependency(producer.getCreatorMethod().getGenericReturnType(), param.getBaseType()))
                         {
                             found = true;
                             break;

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=1502035&r1=1502034&r2=1502035&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 Wed Jul 10 22:48:58 2013
@@ -20,9 +20,7 @@ package org.apache.webbeans.config;
 
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.List;
 
 /**
  * Custom parametrized type implementation.
@@ -38,30 +36,26 @@ public class OwbParametrizedTypeImpl imp
     private final Type rawType;
     
     /**Actual type arguments*/
-    private final List<Type> types = new ArrayList<Type>();
+    private final Type[] types;
 
     /**
      * New instance.
      * @param owner owner
      * @param raw raw
      */
-    public OwbParametrizedTypeImpl(Type owner, Type raw)
+    public OwbParametrizedTypeImpl(Type owner, Type raw, Type... types)
     {
         this.owner = owner;
-        rawType = raw;
+        this.rawType = raw;
+        this.types = types;
     }
     
     @Override
     public Type[] getActualTypeArguments()
     {
-        return types.toArray(new Type[types.size()]);
+        return types.clone();
     }
     
-    public void addTypeArgument(Type type)
-    {
-        types.add(type);
-    }
-
     @Override
     public Type getOwnerType()
     {
@@ -82,12 +76,7 @@ public class OwbParametrizedTypeImpl imp
     @Override
     public int hashCode()
     {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + Arrays.hashCode(getActualTypeArguments());
-        result = prime * result + ((owner == null) ? 0 : owner.hashCode());
-        result = prime * result + ((rawType == null) ? 0 : rawType.hashCode());
-        return result;
+       return Arrays.hashCode(types) ^ (owner == null ? 0 : owner.hashCode()) ^ (rawType == null ? 0 : rawType.hashCode());
     }
 
     /* (non-Javadoc)
@@ -96,47 +85,24 @@ public class OwbParametrizedTypeImpl imp
     @Override
     public boolean equals(Object obj)
     {
-        if (this == obj)
-        {
-            return true;
-        }
-        if (obj == null)
-        {
-            return false;
-        }
-        if (getClass() != obj.getClass())
-        {
-            return false;
-        }
-        OwbParametrizedTypeImpl other = (OwbParametrizedTypeImpl) obj;
-        if (!Arrays.equals(getActualTypeArguments(), other.getActualTypeArguments()))
-        {
-            return false;
-        }
-        if (owner == null)
-        {
-            if (other.owner != null)
-            {
-                return false;
-            }
-        }
-        else if (!owner.equals(other.owner))
-        {
-            return false;
-        }
-        if (rawType == null)
-        {
-            if (other.rawType != null)
-            {
-                return false;
-            }
-        }
-        else if (!rawType.equals(other.rawType))
-        {
-            return false;
-        }
-        
-        return true;
+       if (this == obj)
+       {
+          return true;
+       }
+       else if (obj instanceof ParameterizedType)
+       {
+          ParameterizedType that = (ParameterizedType) obj;
+          Type thatOwnerType = that.getOwnerType();
+          Type thatRawType = that.getRawType();
+          return (owner == null ? thatOwnerType == null : owner.equals(thatOwnerType))
+                  && (rawType == null ? thatRawType == null : rawType.equals(thatRawType))
+                  && Arrays.equals(types, that.getActualTypeArguments());
+       }
+       else
+       {
+          return false;
+       }
+       
     }
 
     public String toString()

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=1502035&r1=1502034&r2=1502035&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 Jul 10 22:48:58 2013
@@ -86,6 +86,7 @@ import org.apache.webbeans.spi.plugins.O
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.GenericsUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 
@@ -688,7 +689,7 @@ public class BeanManagerImpl extends Abs
         //Check type if bean type is given
         if(beanType != null)
         {
-            if(!isBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof NewBean) && !ClassUtil.isAssignable(bean.getBeanClass(), beanType))
+            if(!isBeanTypeAssignableToGivenType(bean.getTypes(), beanType, bean instanceof NewBean) && !GenericsUtil.satisfiesDependency(beanType, bean.getBeanClass()))
             {
                 throw new IllegalArgumentException("Given bean type : " + beanType + " is not applicable for the bean instance : " + bean);
             }
@@ -747,7 +748,7 @@ public class BeanManagerImpl extends Abs
         {
             Type beanApiType = itBeanApiTypes.next();
 
-            if(ClassUtil.isAssignable(beanApiType, givenType))
+            if(GenericsUtil.satisfiesDependency(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=1502035&r1=1502034&r2=1502035&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 Jul 10 22:48:58 2013
@@ -50,6 +50,7 @@ import org.apache.webbeans.spi.ScannerSe
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.GenericsUtil;
 import org.apache.webbeans.util.InjectionExceptionUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 import static org.apache.webbeans.util.InjectionExceptionUtil.throwAmbiguousResolutionException;
@@ -500,7 +501,7 @@ public class InjectionResolver
                 for (Type componentApiType : component.getTypes())
                 {
 
-                    if (ClassUtil.isAssignable(componentApiType, injectionPointType))
+                    if (GenericsUtil.satisfiesDependency(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=1502035&r1=1502034&r2=1502035&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 Jul 10 22:48:58 2013
@@ -35,6 +35,7 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.GenericsUtil;
 
 public class DecoratorsManager
 {
@@ -176,6 +177,7 @@ public class DecoratorsManager
 
     private boolean isDecoratorMatch(Decorator<?> decorator, Set<Type> apiTypes, Set<Annotation> annotations)
     {
+        // 8.3.1
         if (!apiTypesMatchDelegateType(decorator, apiTypes))
         {
             return false;
@@ -218,7 +220,7 @@ public class DecoratorsManager
         boolean ok = false;
         for (Type apiType : apiTypes)
         {
-            if (DecoratorResolverRules.compareType(decorator.getDelegateType(), apiType))
+            if (GenericsUtil.satisfiesDependency(decorator.getDelegateType(), apiType))
             {
                 ok = true;
                 break;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java Wed Jul 10 22:48:58 2013
@@ -324,7 +324,7 @@ public class ObserverMethodImpl<T> imple
                     annotationManager.getQualifierAnnotations(AnnotationUtil.
                             asArray(parameter.getAnnotations()));
 
-                InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(bean, parameter.getBaseType(), parameter, bindingTypes);
+                InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(bean, parameter, bindingTypes);
 
                 //Get observer parameter instance
                 @SuppressWarnings("unchecked")

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java Wed Jul 10 22:48:58 2013
@@ -21,7 +21,6 @@ package org.apache.webbeans.inject.impl;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -131,7 +130,7 @@ public class InjectionPointFactory
             }
         }
 
-        return new InjectionPointImpl(owner, annotField.getBaseType(), Arrays.asList(qualifierAnnots), annotField);
+        return new InjectionPointImpl(owner, Arrays.asList(qualifierAnnots), annotField);
     }
 
     public <X> InjectionPoint buildInjectionPoint(Bean<?> owner, AnnotatedParameter<X> parameter)
@@ -139,7 +138,7 @@ public class InjectionPointFactory
         Asserts.assertNotNull(parameter, "parameter parameter can not be null");
         Set<Annotation> anns = parameter.getAnnotations();
         Annotation[] qualifierAnnots = webBeansContext.getAnnotationManager().getQualifierAnnotations(anns.toArray(new Annotation[anns.size()]));
-        return new InjectionPointImpl(owner, parameter.getBaseType(), Arrays.asList(qualifierAnnots), parameter);
+        return new InjectionPointImpl(owner, Arrays.asList(qualifierAnnots), parameter);
     }
 
     public <X> List<InjectionPoint> buildInjectionPoints(Bean<?> owner, AnnotatedCallable<X> callable)
@@ -165,9 +164,9 @@ public class InjectionPointFactory
         }
     }
 
-    public static InjectionPoint getPartialInjectionPoint(Bean<?> owner,Type type, AnnotatedParameter<?> parameter, Annotation...bindings)
+    public static InjectionPoint getPartialInjectionPoint(Bean<?> owner, AnnotatedParameter<?> parameter, Annotation...bindings)
     {
-        return new InjectionPointImpl(owner, type, Arrays.asList(bindings), parameter);
+        return new InjectionPointImpl(owner, Arrays.asList(bindings), parameter);
     }
 
     private void validateInitializerConstructor(AnnotatedConstructor<?> constructor)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java Wed Jul 10 22:48:58 2013
@@ -71,15 +71,15 @@ class InjectionPointImpl implements Inje
     
     private boolean delegate;
     
-    InjectionPointImpl(Bean<?> ownerBean, Type type, Collection<Annotation> qualifiers, AnnotatedField<?> annotatedField)
+    InjectionPointImpl(Bean<?> ownerBean, Collection<Annotation> qualifiers, AnnotatedField<?> annotatedField)
     {
-        this(ownerBean, type, qualifiers, annotatedField,
+        this(ownerBean, annotatedField.getBaseType(), qualifiers, annotatedField,
                 annotatedField.getJavaMember(), annotatedField.isAnnotationPresent(Delegate.class), Modifier.isTransient(annotatedField.getJavaMember().getModifiers()));
     }
     
-    InjectionPointImpl(Bean<?> ownerBean, Type type, Collection<Annotation> qualifiers, AnnotatedParameter<?> parameter)
+    InjectionPointImpl(Bean<?> ownerBean, Collection<Annotation> qualifiers, AnnotatedParameter<?> parameter)
     {
-        this(ownerBean, type, qualifiers, parameter, parameter.getDeclaringCallable().getJavaMember(), parameter.isAnnotationPresent(Delegate.class), false);
+        this(ownerBean, parameter.getBaseType(), qualifiers, parameter, parameter.getDeclaringCallable().getJavaMember(), parameter.isAnnotationPresent(Delegate.class), false);
     }
     
     private InjectionPointImpl(Bean<?> ownerBean, Type type, Collection<Annotation> qualifiers, Annotated annotated, Member member, boolean delegate, boolean isTransient)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java Wed Jul 10 22:48:58 2013
@@ -32,6 +32,7 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.GenericsUtil;
 
 /**
  * Abstract implementation of the {@link Annotated} contract.
@@ -52,7 +53,7 @@ abstract class AbstractAnnotated impleme
     private final WebBeansContext webBeansContext;
     
     /**
-     * Createa a new annotated element.
+     * Creates a new annotated element.
      *
      * @param webBeansContext our WebBeansContext
      * @param baseType annotated element type
@@ -142,18 +143,19 @@ abstract class AbstractAnnotated impleme
     {
         if (typeClosures == null)
         {
-            initTypeClosures();
+            initTypeClosure();
         }
         return typeClosures;
     }
 
-    private synchronized void initTypeClosures()
+    protected abstract Class<?> getOwningClass();
+    protected abstract Class<?> getDeclaringClass();
+
+    private synchronized void initTypeClosure()
     {
         if (typeClosures == null)
         {
-            typeClosures = new HashSet<Type>();
-            typeClosures.add(Object.class);
-            ClassUtil.setTypeHierarchy(typeClosures, baseType);
+            typeClosures = GenericsUtil.getTypeClosure(baseType, getOwningClass(), getDeclaringClass());
             Set<String> ignoredInterfaces = webBeansContext.getOpenWebBeansConfiguration().getIgnoredInterfaces();
             for (Iterator<Type> i = typeClosures.iterator(); i.hasNext(); )
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotatedMember.java Wed Jul 10 22:48:58 2013
@@ -42,7 +42,6 @@ abstract class AbstractAnnotatedMember<X
     /**Member type*/
     protected final Member javaMember;
     
-    @SuppressWarnings("unchecked")
     AbstractAnnotatedMember(WebBeansContext webBeansContext, Type baseType, Member javaMember, AnnotatedType<X> declaringType)
     {
         super(webBeansContext, baseType);
@@ -83,6 +82,18 @@ abstract class AbstractAnnotatedMember<X
         return Modifier.isStatic(javaMember.getModifiers());
     }
 
+    @Override
+    protected Class<?> getOwningClass()
+    {
+        return declaringType.getJavaClass();
+    }
+
+    @Override
+    protected Class<?> getDeclaringClass()
+    {
+        return javaMember.getDeclaringClass();
+    }
+
     public String toString()
     {
         StringBuilder builder = new StringBuilder(super.toString());

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedConstructorImpl.java Wed Jul 10 22:48:58 2013
@@ -19,6 +19,7 @@
 package org.apache.webbeans.portable;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.util.GenericsUtil;
 
 import java.lang.reflect.Constructor;
 
@@ -43,7 +44,7 @@ public class AnnotatedConstructorImpl<X>
     {        
         super(webBeansContext, javaMember.getDeclaringClass(), javaMember, declaringType);
         setAnnotations(javaMember.getDeclaredAnnotations());
-        setAnnotatedParameters(javaMember.getGenericParameterTypes(), javaMember.getParameterAnnotations());
+        setAnnotatedParameters(GenericsUtil.resolveParameterTypes(declaringType.getJavaClass(), javaMember), javaMember.getParameterAnnotations());
     }
     
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedFieldImpl.java Wed Jul 10 22:48:58 2013
@@ -19,6 +19,7 @@
 package org.apache.webbeans.portable;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.util.GenericsUtil;
 
 import java.lang.reflect.Field;
 
@@ -43,7 +44,7 @@ public class AnnotatedFieldImpl<X> exten
      */
     AnnotatedFieldImpl(WebBeansContext webBeansContext, Field javaMember, AnnotatedType<X> declaringType)
     {
-        super(webBeansContext, javaMember.getGenericType(), javaMember,declaringType);
+        super(webBeansContext, GenericsUtil.resolveType(declaringType.getJavaClass(), javaMember), javaMember,declaringType);
         
         setAnnotations(javaMember.getDeclaredAnnotations());
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedMethodImpl.java Wed Jul 10 22:48:58 2013
@@ -19,6 +19,7 @@
 package org.apache.webbeans.portable;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.util.GenericsUtil;
 
 import java.lang.reflect.Method;
 
@@ -41,11 +42,11 @@ class AnnotatedMethodImpl<X> extends Abs
      * @param declaringType declaring type
      * @param javaMember method
      */
-    AnnotatedMethodImpl(WebBeansContext webBeansContext, Method javaMember,AnnotatedType<X> declaringType)
+    AnnotatedMethodImpl(WebBeansContext webBeansContext, Method javaMember, AnnotatedType<X> declaringType)
     {        
-        super(webBeansContext, javaMember.getGenericReturnType(), javaMember,declaringType);
+        super(webBeansContext, GenericsUtil.resolveReturnType(declaringType.getJavaClass(), javaMember), javaMember,declaringType);
         setAnnotations(javaMember.getDeclaredAnnotations());
-        setAnnotatedParameters(javaMember.getGenericParameterTypes(), javaMember.getParameterAnnotations());
+        setAnnotatedParameters(GenericsUtil.resolveParameterTypes(declaringType.getJavaClass(), javaMember), javaMember.getParameterAnnotations());
     }
     
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java Wed Jul 10 22:48:58 2013
@@ -75,4 +75,16 @@ class AnnotatedParameterImpl<X> extends 
         
         return builder.toString();
     }
+
+    @Override
+    protected Class<?> getOwningClass()
+    {
+        return declaringCallable.getDeclaringType().getJavaClass();
+    }
+
+    @Override
+    protected Class<?> getDeclaringClass()
+    {
+        return declaringCallable.getJavaMember().getDeclaringClass();
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedTypeImpl.java Wed Jul 10 22:48:58 2013
@@ -132,6 +132,18 @@ class AnnotatedTypeImpl<X>
         return getState().methods;
     }
 
+    @Override
+    protected Class<?> getOwningClass()
+    {
+        return getJavaClass();
+    }
+
+    @Override
+    protected Class<?> getDeclaringClass()
+    {
+        return getJavaClass();
+    }
+
     private State getState()
     {
         State result = state;
@@ -153,7 +165,6 @@ class AnnotatedTypeImpl<X>
         return result;
     }
 
-
     private class State
     {
 
@@ -230,12 +241,15 @@ class AnnotatedTypeImpl<X>
 
             if (supertype != null)
             {
-                fields.addAll(supertype.getFields());
+                for (AnnotatedField<? super X> field: supertype.getFields())
+                {
+                    fields.add(new AnnotatedFieldImpl<X>(getWebBeansContext(), field.getJavaMember(), AnnotatedTypeImpl.this));
+                }
                 for (AnnotatedMethod<? super X> method : supertype.getMethods())
                 {
                     if (!isOverridden(method))
                     {
-                        methods.add(method);
+                        methods.add(new AnnotatedMethodImpl<X>(getWebBeansContext(), method.getJavaMember(), AnnotatedTypeImpl.this));
                     }
                 }
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java Wed Jul 10 22:48:58 2013
@@ -18,14 +18,6 @@
  */
 package org.apache.webbeans.util;
 
-import org.apache.webbeans.config.BeanTypeSetResolver;
-import org.apache.webbeans.exception.WebBeansException;
-import org.apache.webbeans.exception.inject.DefinitionException;
-
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.inject.Provider;
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -41,6 +33,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.exception.inject.DefinitionException;
+
 /**
  * Utility classes with respect to the class operations.
  *
@@ -124,21 +121,24 @@ public final class ClassUtil
         return clazz.isMemberClass();
     }
 
-    public static Class<?>  getPrimitiveWrapper(Class<?> clazz)
+    public static boolean isSame(Type type1, Type type2)
     {
-        Asserts.nullCheckForClass(clazz);
-        
-        return PRIMITIVE_TO_WRAPPERS_MAP.get(clazz);
-
+        if ((type1 instanceof Class) && ((Class<?>)type1).isPrimitive())
+        {
+            type1 = PRIMITIVE_TO_WRAPPERS_MAP.get(type1);
+        }
+        if ((type2 instanceof Class) && ((Class<?>)type2).isPrimitive())
+        {
+            type2 = PRIMITIVE_TO_WRAPPERS_MAP.get(type2);
+        }
+        return type1 == type2;
     }
 
-    public static Class<?> identityOrGetPrimitiveWrapper(Class<?> clazz)
+    public static Class<?> getPrimitiveWrapper(Class<?> clazz)
     {
-        if (clazz.isPrimitive())
-        {
-            return getPrimitiveWrapper(clazz);
-        }
-        return clazz;
+        Asserts.nullCheckForClass(clazz);
+        
+        return PRIMITIVE_TO_WRAPPERS_MAP.get(clazz);
 
     }
 
@@ -326,7 +326,6 @@ public final class ClassUtil
         return getObjectMethodNames().contains(methodName);
     }
 
-
     /**
      * Returns true if type is an instance of <code>ParameterizedType</code>
      * else otherwise.
@@ -426,131 +425,6 @@ public final class ClassUtil
     }
 
     /**
-     * See specification 5.2.3.
-     * @param beanType bean type
-     * @param requiredType required type
-     * @return true if assignable
-     */
-    public static boolean isAssignable(Type beanType, Type requiredType)
-    {
-        Asserts.assertNotNull(beanType, "beanType parameter can not be null");
-        Asserts.assertNotNull(requiredType, "requiredType parameter can not be null");
-        
-        //Bean and required types are ParametrizedType
-        if (beanType instanceof ParameterizedType && requiredType instanceof ParameterizedType)
-        {
-            return isAssignableForParametrized((ParameterizedType) beanType, (ParameterizedType) requiredType);
-        }
-        //Both type is class type
-        else if (beanType instanceof Class && requiredType instanceof Class)
-        {
-            Class<?> clzBeanType = (Class<?>)beanType;
-            Class<?> clzReqType = (Class<?>)requiredType;
-            
-            if(clzBeanType.isPrimitive())
-            {
-                clzBeanType = getPrimitiveWrapper(clzBeanType);
-            }
-            
-            if(clzReqType.isPrimitive())
-            {
-                clzReqType = getPrimitiveWrapper(clzReqType);
-            }
-            
-            return clzReqType.equals(clzBeanType);
-        }
-        //Bean type is Parametrized and required type is class type
-        else if(beanType instanceof ParameterizedType && requiredType instanceof Class)
-        {
-            boolean ok = true;
-            ParameterizedType ptBean = (ParameterizedType)beanType;
-            Class<?> clazzBeanType = identityOrGetPrimitiveWrapper((Class<?>)ptBean.getRawType());
-            Class<?> clazzReqType = identityOrGetPrimitiveWrapper((Class<?>)requiredType);
-            if(clazzBeanType.equals(clazzReqType))
-            {
-                Type[]  beanTypeArgs = ptBean.getActualTypeArguments();               
-                for(Type actual : beanTypeArgs)
-                {
-                    if(!ClassUtil.isUnboundedTypeVariable(actual))
-                    {
-                        if(actual instanceof Class)
-                        {
-                            Class<?> clazz = (Class<?>)actual;
-                            if(!clazz.equals(Object.class))
-                            {
-                                ok = false;
-                                break;
-                            }
-                        }
-                        else
-                        {
-                            ok = false;
-                            break;
-                        }
-                    }
-                }                
-            }
-            else
-            {
-                ok = false;
-            }
-            
-            
-            return ok;
-        }
-        //Bean type is class and required type is parametrized
-        else if(beanType instanceof Class && requiredType instanceof ParameterizedType)
-        {
-            final Class<?> clazzBeanType = (Class<?>)beanType;
-            final ParameterizedType ptReq = (ParameterizedType)requiredType;
-            final Class<?> clazzReqType = (Class<?>)ptReq.getRawType();
-            final Type genericSuperClass = clazzBeanType.getGenericSuperclass();
-
-            if (Provider.class.isAssignableFrom(clazzReqType) ||
-                    Event.class.isAssignableFrom(clazzReqType))
-            {
-                if (isClassAssignable(clazzReqType, clazzBeanType))
-                {
-                    return true;
-                }
-            }
-            else if (Bean.class.isAssignableFrom(clazzReqType))
-            {
-                // May be Bean, Interceptor or Decorator and thus must match directly
-                if (clazzReqType.equals(clazzBeanType))
-                {
-                    return true;
-                }
-            }
-            else if (genericSuperClass instanceof ParameterizedType)
-            {
-                final Type[] params = ((ParameterizedType) genericSuperClass).getActualTypeArguments();
-                final Type[] requiredParams = ((ParameterizedType) requiredType).getActualTypeArguments();
-                if (params.length != requiredParams.length)
-                {
-                    return false;
-                }
-
-                for (int i = 0; i < params.length; i++)
-                {
-                    if (!isAssignable(params[i], requiredParams[i]))
-                    {
-                        return false;
-                    }
-                }
-
-                return isClassAssignable(clazzReqType, clazzBeanType);
-            }
-
-            return false;
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    /**
      * Checks that event is applicable
      * for the given observer type.
      * @param eventType event type
@@ -718,7 +592,13 @@ public final class ClassUtil
                     ok++;
                 }
             }
-
+            else if (requiredTypeArg instanceof ParameterizedType && beanTypeArg instanceof TypeVariable)
+            {
+                if (checkRequiredTypeIsParameterizedAndBeanTypeIsVariable(beanTypeArg, requiredTypeArg))
+                {
+                    ok++;
+                }
+            }
             //Both type is actual type
             else if((beanTypeArg instanceof Class) && (requiredTypeArg instanceof Class))
             {
@@ -874,6 +754,7 @@ public final class ClassUtil
         Class<?> clazzRequiredType = (Class<?>)requiredTypeArg;
         
         TypeVariable<?> tvBeanTypeArg = (TypeVariable<?>)beanTypeArg;
+        //TODO respect other bounds
         Type tvBound = tvBeanTypeArg.getBounds()[0];
         
         if(tvBound instanceof Class)
@@ -891,6 +772,13 @@ public final class ClassUtil
         
         return true;
     }
+
+    public static boolean checkRequiredTypeIsParameterizedAndBeanTypeIsVariable(Type beanTypeArg, Type requiredTypeArg)
+    {
+        ParameterizedType requiredType = (ParameterizedType)requiredTypeArg;
+        //TODO respect parameters of required type
+        return checkRequiredTypeIsClassAndBeanTypeIsVariable(beanTypeArg, requiredType.getRawType());
+    }
     
     public static boolean checkRequiredTypeIsTypeVariableAndBeanTypeIsClass(Type beanTypeArg, Type requiredTypeArg)
     {
@@ -972,16 +860,6 @@ public final class ClassUtil
         }
     }
 
-
-    public static Set<Type> setTypeHierarchy(Set<Type> set, Type clazz)
-    {
-        BeanTypeSetResolver resolver = new BeanTypeSetResolver(clazz);
-        resolver.startConfiguration();
-        set.addAll(resolver.getHierarchy());
-        
-        return set;
-    }
-
     /**
      * Return raw class type for given type.
      * @param type base type instance

Added: 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=1502035&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java Wed Jul 10 22:48:58 2013
@@ -0,0 +1,625 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.util;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.webbeans.config.OwbParametrizedTypeImpl;
+import org.apache.webbeans.exception.inject.DefinitionException;
+
+/**
+ * Utility classes for generic type operations.
+ */
+public final class GenericsUtil
+{
+    public static boolean satisfiesDependency(Type injectionPointType, Type beanType)
+    {
+        validate(injectionPointType);
+        if (injectionPointType instanceof TypeVariable || injectionPointType instanceof WildcardType || injectionPointType instanceof GenericArrayType)
+        {
+            throw new DefinitionException("Injection point cannot define Type Variable " + injectionPointType);
+        }
+        if (beanType instanceof TypeVariable || beanType instanceof WildcardType || beanType instanceof GenericArrayType)
+        {
+            return isAssignableFrom(injectionPointType, beanType);
+        }
+        else
+        {
+            Type injectionPointRawType = injectionPointType instanceof ParameterizedType? ((ParameterizedType)injectionPointType).getRawType(): injectionPointType;
+            Type beanRawType = beanType instanceof ParameterizedType? ((ParameterizedType)beanType).getRawType(): beanType;
+            
+            return ClassUtil.isSame(injectionPointRawType, beanRawType)? isAssignableFrom(injectionPointType, beanType): false;
+        }
+    }
+
+    /**
+     * 5.2.3 and 5.2.4
+     */
+    public static boolean isAssignableFrom(Type requiredType, Type beanType)
+    {
+        if (requiredType instanceof Class)
+        {
+            return isAssignableFrom((Class<?>)requiredType, beanType);
+        }
+        else if (requiredType instanceof ParameterizedType)
+        {
+            return isAssignableFrom((ParameterizedType)requiredType, beanType);
+        }
+        else if (requiredType instanceof TypeVariable)
+        {
+            return isAssignableFrom((TypeVariable<?>)requiredType, beanType);
+        }
+        else if (requiredType instanceof GenericArrayType)
+        {
+            return isAssignableFrom((GenericArrayType)requiredType, beanType);
+        }
+        else if (requiredType instanceof WildcardType)
+        {
+            return isAssignableFrom((WildcardType)requiredType, beanType);
+        }
+        else
+        {
+            throw new IllegalArgumentException("Unsupported type " + requiredType.getClass());
+        }
+    }
+
+    private static boolean isAssignableFrom(Class<?> injectionPointType, Type beanType)
+    {
+        if (beanType instanceof Class)
+        {
+            return isAssignableFrom(injectionPointType, (Class<?>)beanType);
+        }
+        else if (beanType instanceof TypeVariable)
+        {
+            return isAssignableFrom(injectionPointType, (TypeVariable<?>)beanType);
+        }
+        else if (beanType instanceof ParameterizedType)
+        {
+            return isAssignableFrom(injectionPointType, (ParameterizedType)beanType);
+        }
+        else if (beanType instanceof GenericArrayType)
+        {
+            return isAssignableFrom(injectionPointType, (GenericArrayType)beanType);
+        }
+        else if (beanType instanceof WildcardType)
+        {
+            return isAssignableFrom((Type)injectionPointType, (WildcardType)beanType);
+        }
+        else
+        {
+            throw new IllegalArgumentException("Unsupported type " + injectionPointType.getClass());
+        }
+    }
+
+    private static boolean isAssignableFrom(Class<?> injectionPointType, Class<?> beanType)
+    {
+        return ClassUtil.isClassAssignable(injectionPointType, beanType);
+    }
+
+    private static boolean isAssignableFrom(Class<?> injectionPointType, TypeVariable<?> beanType)
+    {
+        for (Type bounds: beanType.getBounds())
+        {
+            if (isAssignableFrom(injectionPointType, bounds))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * CDI Spec. 5.2.4: "A parameterized bean type is considered assignable to a raw required type
+     * if the raw types are identical and all type parameters of the bean type are either unbounded type variables or java.lang.Object." 
+     */
+    private static boolean isAssignableFrom(Class<?> injectionPointType, ParameterizedType beanType)
+    {
+        if (beanType.getRawType() != injectionPointType)
+        {
+            return false; //raw types don't match
+        }
+        for (Type typeArgument: beanType.getActualTypeArguments())
+        {
+            if (typeArgument == Object.class)
+            {
+                continue;
+            }
+            if (!(typeArgument instanceof TypeVariable))
+            {
+                return false; //neither object nor type variable
+            }
+            TypeVariable<?> typeVariable = (TypeVariable<?>)typeArgument;
+            for (Type bounds: typeVariable.getBounds())
+            {
+                if (bounds != Object.class)
+                {
+                    return false; //bound type variable
+                }
+            }
+        }
+        return true;
+    }
+
+    private static boolean isAssignableFrom(Class<?> injectionPointType, GenericArrayType beanType)
+    {
+        if (!injectionPointType.isArray())
+        {
+            return false;
+        }
+        return isAssignableFrom(injectionPointType.getComponentType(), beanType.getGenericComponentType());
+    }
+    
+    private static boolean isAssignableFrom(Type injectionPointType, WildcardType beanType)
+    {
+        for (Type bounds: beanType.getLowerBounds())
+        {
+            if (!isAssignableFrom(bounds, injectionPointType))
+            {
+                return false;
+            }
+        }
+        for (Type bounds: beanType.getUpperBounds())
+        {
+            if (isAssignableFrom(injectionPointType, bounds))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static boolean isAssignableFrom(ParameterizedType injectionPointType, Type beanType)
+    {
+        if (beanType instanceof Class)
+        {
+            return isAssignableFrom(injectionPointType, (Class<?>)beanType);
+        }
+        else if (beanType instanceof TypeVariable)
+        {
+            return isAssignableFrom(injectionPointType, (TypeVariable<?>)beanType);
+        }
+        else if (beanType instanceof ParameterizedType)
+        {
+            return isAssignableFrom(injectionPointType, (ParameterizedType)beanType);
+        }
+        else if (beanType instanceof WildcardType)
+        {
+            return isAssignableFrom((Type)injectionPointType, (WildcardType)beanType);
+        }
+        else if (beanType instanceof GenericArrayType)
+        {
+            return false;
+        }
+        else
+        {
+            throw new IllegalArgumentException("Unsupported type " + injectionPointType.getClass());
+        }
+    }
+
+    private static boolean isAssignableFrom(ParameterizedType injectionPointType, Class<?> beanType)
+    {
+        return isAssignableFrom(injectionPointType.getRawType(), beanType);
+    }
+
+    private static boolean isAssignableFrom(ParameterizedType injectionPointType, TypeVariable<?> beanType)
+    {
+        for (Type bounds: beanType.getBounds())
+        {
+            if (isAssignableFrom(injectionPointType, bounds))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * CDI Spec. 5.2.4
+     */
+    private static boolean isAssignableFrom(ParameterizedType injectionPointType, ParameterizedType beanType)
+    {
+        if (injectionPointType.getRawType() != beanType.getRawType())
+        {
+            return false;
+        }
+        Type[] injectionPointTypeArguments = injectionPointType.getActualTypeArguments();
+        Type[] beanTypeArguments = beanType.getActualTypeArguments();
+        for (int i = 0; i < injectionPointTypeArguments.length; i++)
+        {
+            if (!isAssignableFrom(injectionPointTypeArguments[i], beanTypeArguments[i]))
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private static boolean isAssignableFrom(TypeVariable<?> injectionPointType, Type beanType)
+    {
+        for (Type bounds: injectionPointType.getBounds())
+        {
+            if (!isAssignableFrom(bounds, beanType))
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private static boolean isAssignableFrom(GenericArrayType injectionPointType, Type beanType)
+    {
+        throw new UnsupportedOperationException("Not yet implementeds");
+    }
+
+    private static boolean isAssignableFrom(WildcardType injectionPointType, Type beanType)
+    {
+        for (Type bounds: injectionPointType.getLowerBounds())
+        {
+            if (!isAssignableFrom(beanType, bounds))
+            {
+                return false;
+            }
+        }
+        for (Type bounds: injectionPointType.getUpperBounds())
+        {
+            if (!isAssignableFrom(bounds, beanType))
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+    
+    /**
+     * Resolves the actual type of the specified field for the type hierarchy specified by the given subclass
+     */
+    public static Type resolveType(Class<?> subclass, Field field)
+    {
+        return resolveType(field.getGenericType(), new TypeVariableResolver(subclass, field.getDeclaringClass()));
+    }
+
+    /**
+     * Resolves the actual return type of the specified method for the type hierarchy specified by the given subclass
+     */
+    public static Type resolveReturnType(Class<?> subclass, Method method)
+    {
+        return resolveType(method.getGenericReturnType(), new TypeVariableResolver(subclass, method.getDeclaringClass()));
+    }
+
+    /**
+     * Resolves the actual parameter types of the specified constructor for the type hierarchy specified by the given subclass
+     */
+    public static Type[] resolveParameterTypes(Class<?> subclass, Constructor<?> constructor)
+    {
+        return resolveTypes(constructor.getGenericParameterTypes(), new TypeVariableResolver(subclass, constructor.getDeclaringClass()));
+    }
+
+    /**
+     * Resolves the actual parameter types of the specified method for the type hierarchy specified by the given subclass
+     */
+    public static Type[] resolveParameterTypes(Class<?> subclass, Method method)
+    {
+        return resolveTypes(method.getGenericParameterTypes(), new TypeVariableResolver(subclass, method.getDeclaringClass()));
+    }
+
+    /**
+     * Resolves the actual type of the specified type for the type hierarchy specified by the given subclass
+     */
+    public static Type resolveType(Type type, Class<?> subclass, Member member)
+    {
+        return resolveType(type, new TypeVariableResolver(subclass, member.getDeclaringClass()));
+    }
+
+    private static Type resolveType(Type type, TypeVariableResolver resolver)
+    {
+        if (type instanceof Class)
+        {
+            return type;
+        }
+        else if (type instanceof ParameterizedType)
+        {
+            ParameterizedType parameterizedType = (ParameterizedType)type;
+            Type[] resolvedTypes = resolveTypes(parameterizedType.getActualTypeArguments(), resolver);
+            return new OwbParametrizedTypeImpl(parameterizedType.getOwnerType(), parameterizedType.getRawType(), resolvedTypes);
+        }
+        else if (type instanceof TypeVariable)
+        {
+            TypeVariable<?> variable = (TypeVariable<?>)type;
+            return resolver.resolve(variable);
+        }
+        else if (type instanceof WildcardType)
+        {
+            Type[] resolvedTypes = resolveTypes(((WildcardType) type).getUpperBounds(), resolver);
+            return resolveType(getMostSpecificType(getRawTypes(resolvedTypes, resolver), resolvedTypes), resolver);
+        }
+        else if (type instanceof GenericArrayType)
+        {
+            Type componentType = resolveType(((GenericArrayType)type).getGenericComponentType(), resolver);
+            Class<?> componentClass = getRawType(componentType, resolver);
+            return Array.newInstance(componentClass, 0).getClass();
+        }
+        else
+        {
+            throw new IllegalArgumentException("Unsupported type " + type.getClass().getName());
+        }
+    }
+    
+    public static Type[] resolveTypes(Type[] types, TypeVariableResolver resolution)
+    {
+        Type[] resolvedTypeArguments = new Type[types.length];
+        for (int i = 0; i < types.length; i++)
+        {
+            resolvedTypeArguments[i] = resolveType(types[i], resolution);
+        }
+        return resolvedTypeArguments;
+    }
+
+    public static Set<Type> getTypeClosure(Type type, Class<?> owningClass, Class<?> declaringClass)
+    {
+        Set<Type> typeClosure = new HashSet<Type>();
+        typeClosure.add(Object.class);
+        fillTypeHierarchy(typeClosure, type, new TypeVariableResolver(owningClass, declaringClass));
+        return typeClosure;
+    }
+
+    private static void fillTypeHierarchy(Set<Type> set, Type type, TypeVariableResolver resolver)
+    {
+        if (type == null)
+        {
+           return;
+        }
+        Type resolvedType = GenericsUtil.resolveType(type, resolver);
+        set.add(resolvedType);
+        Class<?> resolvedClass = GenericsUtil.getRawType(resolvedType, resolver);
+        if (resolvedClass.getSuperclass() != null)
+        {
+            fillTypeHierarchy(set, resolvedClass.getGenericSuperclass(), resolver.add(resolvedClass));
+        }
+        for (Type interfaceType: resolvedClass.getGenericInterfaces())
+        {
+            fillTypeHierarchy(set, interfaceType, resolver.add(resolvedClass, interfaceType));
+        }
+    }
+
+    static <T> Class<T> getRawType(Type type, TypeVariableResolver resolver)
+    {
+        if (type instanceof Class)
+        {
+            return (Class<T>)type;
+        }
+        else if (type instanceof ParameterizedType)
+        {
+            return getRawType(((ParameterizedType) type).getRawType(), resolver);
+        }
+        else if ((type instanceof TypeVariable) || (type instanceof WildcardType) || (type instanceof GenericArrayType))
+        {
+            Type resolvedType = resolveType(type, resolver);
+            if (resolvedType instanceof TypeVariable)
+            {
+                TypeVariable<?> variable = (TypeVariable<?>)resolvedType;
+                return getRawType(resolveType(getRawType(variable.getBounds(), resolver), resolver), resolver);
+            }
+            else
+            {
+                return getRawType(resolvedType, resolver);
+            }
+        }
+        else
+        {
+            throw new IllegalArgumentException("Unsupported type " + type.getClass().getName());
+        }
+    }
+
+    private static Type getRawType(Type[] types, TypeVariableResolver resolver)
+    {
+        Class<?>[] rawTypes = getRawTypes(types, resolver);
+        Class<?>[] classTypes = getClassTypes(rawTypes);
+        if (classTypes.length > 0)
+        {
+            return getMostSpecificType(classTypes, types);
+        }
+        else
+        {
+            return getMostSpecificType(rawTypes, types);
+        }
+    }
+
+    private static <T> Class<T>[] getRawTypes(Type[] types, TypeVariableResolver resolver)
+    {
+        Class<T>[] rawTypes = new Class[types.length];
+        for (int i = 0; i < types.length; i++)
+        {
+            rawTypes[i] = getRawType(types[i], resolver);
+        }
+        return rawTypes;
+    }
+
+    private static Type getMostSpecificType(Class<?>[] types, Type[] genericTypes)
+    {
+        Class<?> mostSpecificType = types[0];
+        int mostSpecificIndex = 0;
+        for (int i = 0; i < types.length; i++) 
+        {
+            if (mostSpecificType.isAssignableFrom(types[i]))
+            {
+                mostSpecificType = types[i];
+                mostSpecificIndex = i;
+            }
+        }
+        return genericTypes[mostSpecificIndex];
+    }
+
+    private static Class<?>[] getClassTypes(Class<?>[] rawTypes)
+    {
+        List<Class<?>> classTypes = new ArrayList<Class<?>>();
+        for (Class<?> rawType : rawTypes)
+        {
+            if (!rawType.isInterface())
+            {
+                classTypes.add(rawType);
+            }
+        }
+        return classTypes.toArray(new Class[classTypes.size()]);
+    }
+
+    private static Type validate(Type type)
+    {
+        if (!(type instanceof Class)
+                && !(type instanceof ParameterizedType)
+                && !(type instanceof TypeVariable)
+                && !(type instanceof GenericArrayType)
+                && !(type instanceof WildcardType))
+        {
+            throw new IllegalArgumentException("Unsupported type " + type.getClass());
+        }
+        return type;
+    }
+
+    /**
+     * resolves actual types of a TypeVariable for a specific type hierarchy
+     */
+    private static class TypeVariableResolver
+    {
+        private List<TypeVariableDeclaration> declarations = new ArrayList<TypeVariableDeclaration>();
+
+        private TypeVariableResolver(List<TypeVariableDeclaration> implementation)
+        {
+            this.declarations = implementation;
+        }
+
+        public TypeVariableResolver(Class<?> subclass, Class<?> declaringClass)
+        {
+            declarations.add(new TypeVariableDeclaration(subclass, subclass.getGenericSuperclass()));
+            while (declaringClass != subclass && declaringClass.isAssignableFrom(subclass))
+            {
+                subclass = subclass.getSuperclass();
+                declarations.add(new TypeVariableDeclaration(subclass, subclass.getGenericSuperclass()));
+            }
+        }
+
+        public Type resolve(TypeVariable<?> variable)
+        {
+            if (declarations.size() < 2)
+            {
+                return getRawType(variable.getBounds(), this);
+            }
+            int hierarchyIndex = declarations.size() - 1;
+            TypeVariableDeclaration typeVariableImplementation = declarations.get(hierarchyIndex);
+            TypeVariable<?>[] typeParameters = typeVariableImplementation.getDeclaredTypeParameters();
+            int typeIndex = -1;
+            for (int i = 0; i < typeParameters.length; i++)
+            {
+                if (variable.getName().equals(typeParameters[i].getName()))
+                {
+                    typeIndex = i;
+                    break;
+                }
+            }
+            if (typeIndex == -1)
+            {
+                // type erasure
+                return Object.class;
+            }
+            TypeVariableDeclaration declaration = declarations.get(hierarchyIndex - 1);
+            Type genericClass = declaration.getAssignment();
+            if (genericClass instanceof ParameterizedType)
+            {
+                ParameterizedType classType = (ParameterizedType)genericClass;
+                return resolveType(classType.getActualTypeArguments()[typeIndex], remove());
+            }
+            else
+            {
+                TypeVariable<?>[] typeVariables = declaration.getDeclaredTypeParameters();
+                if (typeVariables.length > typeIndex)
+                {
+                    return resolveType(typeVariables[typeIndex], remove());
+                }
+                else
+                {
+                    return Object.class; //type erasure
+                }
+            }
+        }
+
+        public TypeVariableResolver add(Class<?> type)
+        {
+            return add(type, type.getGenericSuperclass());
+        }
+
+        public TypeVariableResolver add(Class<?> declaringClass, Type assignment)
+        {
+            List<TypeVariableDeclaration> declarations = new ArrayList<TypeVariableDeclaration>(this.declarations);
+            declarations.add(new TypeVariableDeclaration(declaringClass, assignment));
+            return new TypeVariableResolver(declarations);
+        }
+
+        public TypeVariableResolver remove()
+        {
+            List<TypeVariableDeclaration> declarations = new ArrayList<TypeVariableDeclaration>(this.declarations);
+            declarations.remove(declarations.size() - 1);
+            return new TypeVariableResolver(declarations);
+        }
+    }
+    
+    /**
+     * A declaration of type variables along with its assignments
+     */
+    private static class TypeVariableDeclaration
+    {
+        private Class<?> declaringClass;
+        private Type assignment;
+        
+        public TypeVariableDeclaration(Class<?> declaringClass, Type assignment)
+        {
+            this.declaringClass = declaringClass;
+            this.assignment = assignment;
+        }
+
+        public Type getAssignment()
+        {
+            return assignment;
+        }
+
+        public TypeVariable<?>[] getDeclaredTypeParameters()
+        {
+            return declaringClass.getTypeParameters();
+        }
+    }
+
+    private static class TypeErasureException extends Exception
+    {
+        public TypeErasureException()
+        {
+            super("generic type information not available");
+        }
+    }
+}

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=1502035&r1=1502034&r2=1502035&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 Jul 10 22:48:58 2013
@@ -1058,16 +1058,7 @@ public final class WebBeansUtil
     {
         Type type = injectionPoint.getType();
 
-        Class<?> candidateClazz = null;
-        if(type instanceof Class)
-        {
-            candidateClazz = (Class<?>)type;
-        }
-        else if(type instanceof ParameterizedType)
-        {
-            ParameterizedType pt = (ParameterizedType)type;
-            candidateClazz = (Class<?>)pt.getRawType();
-        }
+        Class<?> candidateClazz = ClassUtil.getClass(type);
 
         if(!candidateClazz.isAssignableFrom(Instance.class))
         {

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/GenericDecoratorTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/GenericDecoratorTest.java?rev=1502035&r1=1502034&r2=1502035&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/GenericDecoratorTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/GenericDecoratorTest.java Wed Jul 10 22:48:58 2013
@@ -86,5 +86,4 @@ public class GenericDecoratorTest extend
         DecoratedBean decoratedBean = getInstance(DecoratedBean.class);
         Assert.assertTrue(decoratedBean.isDecoratorCalled());
     }
-
 }

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Bar.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Bar.java?rev=1502035&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Bar.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Bar.java Wed Jul 10 22:48:58 2013
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.injection.generics;
+
+import java.util.List;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Typed;
+import javax.inject.Inject;
+
+@Typed
+public class Bar<A, B> {
+
+    @Inject
+    @GenericQualifier
+    private Baz<A> baz;
+
+    @Inject
+    @GenericQualifier
+    private A a;
+
+    @Inject
+    private Baz<List<B>> bBazList;
+    private A[] aArray;
+    private Baz<A> aBazEvent;
+    private A aObserverInjectionPoint;
+
+    @Inject
+    public void setAArray(A[] aArray) {
+        this.aArray = aArray;
+    }
+
+    public void observeBaz(@Observes Baz<A> baz, @GenericQualifier A a) {
+        this.aBazEvent = baz;
+        this.aObserverInjectionPoint = a;
+    }
+
+    public Baz<A> getBaz() {
+        return this.baz;
+    }
+
+    public Baz<List<B>> getBBazList() {
+        return this.bBazList;
+    }
+
+    public A getA() {
+        return this.a;
+    }
+
+    public A[] getAArray() {
+        return this.aArray;
+    }
+
+    public Baz<A> getABazEvent() {
+        return this.aBazEvent;
+    }
+
+    public A getAObserverInjectionPoint() {
+        return this.aObserverInjectionPoint;
+    }
+}
\ No newline at end of file

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BarVetoExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BarVetoExtension.java?rev=1502035&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BarVetoExtension.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BarVetoExtension.java Wed Jul 10 22:48:58 2013
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.injection.generics;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+public class BarVetoExtension implements Extension {
+    
+    public void vetoBar(@Observes ProcessAnnotatedType<?> annotatedTypeEvent)
+    {
+        if (annotatedTypeEvent.getAnnotatedType().getJavaClass().equals(Bar.class))
+        {
+            annotatedTypeEvent.veto();
+        }
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Baz.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Baz.java?rev=1502035&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Baz.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/Baz.java Wed Jul 10 22:48:58 2013
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.injection.generics;
+
+public class Baz<T> {
+
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BazSubclass.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BazSubclass.java?rev=1502035&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BazSubclass.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/generics/BazSubclass.java Wed Jul 10 22:48:58 2013
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.injection.generics;
+
+
+public class BazSubclass extends Baz<String> {
+
+    public BazSubclass(String string)
+    {
+    }
+}



Mime
View raw message