[jboss-cvs] JBossAS SVN: r58838 - in projects/microcontainer/trunk/container/src: main/org/jboss main/org/jboss/beans/info/plugins main/org/jboss/reflect/plugins main/org/jboss/reflect/plugins/introspection main/org/jboss/reflect/plugins/javassist main/org/jboss/reflect/spi main/org/jboss/util main/org/jboss/util/collection main/org/jboss/util/collection/temp tests/org/jboss/test/classinfo/support tests/org/jboss/test/classinfo/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 4 09:41:15 EST 2006


Author: adrian at jboss.org
Date: 2006-12-04 09:40:50 -0500 (Mon, 04 Dec 2006)
New Revision: 58838

Added:
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedArrayInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/util/
   projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/
   projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/
   projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/FIXME
   projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/WeakTypeCache.java
   projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/WeakValueHashMap.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericClass.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericConstructorsClass.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericFieldsClass.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericFieldsInterface.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericInterface.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericMethodsClass.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericMethodsInterface.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassEmptyClass.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassString.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceEmptyClass.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceString.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoGenericClassTest.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoGenericInterfaceTest.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/IntrospectionGenericClassUnitTestCase.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/IntrospectionGenericInterfaceUnitTestCase.java
Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ArrayInfoImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoHelper.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistArrayInfoImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/ClassInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfoFactory.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoTestSuite.java
Log:
Generification of the TypeInfo api.

TODO:
* Complete the support for TypeVariable and GenericArray
* Implement this for the javassist version
* Move the org.jboss.util.collection.temp to the common-core project once
it properly supports JDK5

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -42,7 +42,7 @@
 import org.jboss.reflect.spi.PrimitiveInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.util.JBossStringBuilder;
-import org.jboss.util.collection.WeakValueHashMap;
+import org.jboss.util.collection.temp.WeakValueHashMap;
 
 /**
  * A bean info factory.
@@ -140,7 +140,7 @@
          BeanInfo result = createBeanInfo(classAdapter, properties, constructors, methods, events);
          if (map == null)
          {
-            map = new WeakValueHashMap();
+            map = new WeakValueHashMap<String, BeanInfo>();
             cache.put(cl, map);
          }
          map.put(className, result);

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ArrayInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ArrayInfoImpl.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ArrayInfoImpl.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -21,7 +21,6 @@
 */
 package org.jboss.reflect.plugins;
 
-import org.jboss.reflect.spi.AnnotatedInfo;
 import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.ArrayInfo;
 import org.jboss.reflect.spi.TypeInfo;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoHelper.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoHelper.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoHelper.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -21,6 +21,8 @@
 */
 package org.jboss.reflect.plugins;
 
+import org.jboss.reflect.plugins.introspection.ParameterizedClassInfo;
+import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.InterfaceInfo;
 import org.jboss.reflect.spi.TypeInfo;
 
@@ -41,6 +43,14 @@
    ClassInfoImpl getSuperClass(ClassInfoImpl classInfo);
 
    /**
+    * Get the generic super class
+    * 
+    * @param classInfo the class info
+    * @return the super class info
+    */
+   ClassInfo getGenericSuperClass(ClassInfoImpl classInfo);
+
+   /**
     * Get the interfaces
     * 
     * @param classInfo the class info
@@ -49,6 +59,14 @@
    InterfaceInfo[] getInterfaces(ClassInfoImpl classInfo);
 
    /**
+    * Get the generic interfaces
+    * 
+    * @param classInfo the class info
+    * @return the interface info
+    */
+   InterfaceInfo[] getGenericInterfaces(ClassInfoImpl classInfo);
+
+   /**
     * Get the constructors
     * 
     * @param classInfo the class info
@@ -79,4 +97,20 @@
     * @return the type info
     */
    TypeInfo getTypeInfo(Class clazz);
+   
+   /**
+    * Get the actual type parameters
+    * 
+    * @param classInfo the parameterized class info
+    * @return the type parameters
+    */
+   TypeInfo[] getActualTypeArguments(ParameterizedClassInfo classInfo);
+   
+   /**
+    * Get the owner type
+    * 
+    * @param classInfo the parameterized class info
+    * @return the owner type
+    */
+   TypeInfo getOwnerType(ParameterizedClassInfo classInfo);
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/ClassInfoImpl.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -48,19 +48,28 @@
    private static final long serialVersionUID = 3545798779904340792L;
 
    /** Marker for generation */
-   static final ClassInfo UNKNOWN_CLASS = new UnknownClassInfo();
+   public static final ClassInfo UNKNOWN_CLASS = new UnknownClassInfo();
 
    /** Marker for generation */
-   static final InterfaceInfo[] UNKNOWN_INTERFACES = new InterfaceInfo[0];
+   public static final ClassInfo[] UNKNOWN_CLASSES = new UnknownClassInfo[0];
 
    /** Marker for generation */
-   static final ConstructorInfo[] UNKNOWN_CONSTRUCTORS = new ConstructorInfo[0];
+   public static final TypeInfo UNKNOWN_TYPE = new UnknownTypeInfo();
 
    /** Marker for generation */
-   static final MethodInfo[] UNKNOWN_METHODS = new MethodInfo[0];
+   public static final TypeInfo[] UNKNOWN_TYPES = new UnknownTypeInfo[0];
 
    /** Marker for generation */
-   private static final FieldInfo[] UNKNOWN_FIELDS = new FieldInfo[0];
+   public static final InterfaceInfo[] UNKNOWN_INTERFACES = new InterfaceInfo[0];
+
+   /** Marker for generation */
+   public static final ConstructorInfo[] UNKNOWN_CONSTRUCTORS = new ConstructorInfo[0];
+
+   /** Marker for generation */
+   public static final MethodInfo[] UNKNOWN_METHODS = new MethodInfo[0];
+
+   /** Marker for generation */
+   public static final FieldInfo[] UNKNOWN_FIELDS = new FieldInfo[0];
    
    /** The class name */
    protected String name;
@@ -71,6 +80,9 @@
    /** The interfaces */
    protected InterfaceInfo[] interfaces = UNKNOWN_INTERFACES;
    
+   /** The generic interfaces */
+   protected InterfaceInfo[] genericInterfaces = UNKNOWN_INTERFACES;
+   
    /** The methods */
    protected MethodInfo[] methods = UNKNOWN_METHODS;
    
@@ -83,6 +95,9 @@
    /** The super class */
    protected ClassInfo superclass = UNKNOWN_CLASS;
 
+   /** The generic super class */
+   protected ClassInfo genericSuperclass = UNKNOWN_CLASS;
+
    /** The constructor info */
    protected ConstructorInfo[] constructors = UNKNOWN_CONSTRUCTORS; 
 
@@ -243,6 +258,16 @@
    {
       this.interfaces = interfaces;
    }
+   
+   /**
+    * Set the generic interfaces
+    * 
+    * @param interfaces the interfaces
+    */
+   public void setGenericInterfaces(InterfaceInfo[] interfaces)
+   {
+      this.genericInterfaces = interfaces;
+   }
 
    /**
     * Set the declared methods
@@ -303,6 +328,15 @@
       this.superclass = superInfo;
    }
 
+   /**
+    * Set the generic super class
+    * 
+    * @param superInfo the super class
+    */
+   public void setGenericSuperclass(ClassInfo superInfo)
+   {
+      this.genericSuperclass = superInfo;
+   }
 
    public boolean isInterface()
    {
@@ -315,6 +349,13 @@
          setInterfaces(classInfoHelper.getInterfaces(this));
       return interfaces;
    }
+
+   public InterfaceInfo[] getGenericInterfaces()
+   {
+      if (genericInterfaces == UNKNOWN_INTERFACES)
+         setGenericInterfaces(classInfoHelper.getGenericInterfaces(this));
+      return genericInterfaces;
+   }
    
    public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
    {
@@ -366,6 +407,13 @@
          setSuperclass(classInfoHelper.getSuperClass(this));
       return superclass;
    }
+
+   public ClassInfo getGenericSuperclass()
+   {
+      if (genericSuperclass == UNKNOWN_CLASS)
+         setGenericSuperclass(classInfoHelper.getGenericSuperClass(this));
+      return genericSuperclass;
+   }
    
    public int getModifiers()
    {
@@ -426,6 +474,21 @@
       return (Object[]) Array.newInstance(clazz.getComponentType(), size);
    }
 
+   public TypeInfo[] getActualTypeArguments()
+   {
+      return null;
+   }
+
+   public TypeInfo getOwnerType()
+   {
+      return null;
+   }
+
+   public ClassInfo getRawType()
+   {
+      return this;
+   }
+
    protected InheritableAnnotationHolder getSuperHolder()
    {
       return (ClassInfoImpl) getSuperclass();
@@ -456,121 +519,137 @@
       return (name != null ? name.hashCode() : 0);
    }
    
-   static class UnknownClassInfo implements ClassInfo
+   public static class UnknownTypeInfo implements TypeInfo
    {
       /** The serialVersionUID */
       private static final long serialVersionUID = 1L;
 
-      public ConstructorInfo[] getDeclaredConstructors()
+      public Object convertValue(Object value) throws Throwable
       {
          throw new UnreachableStatementException();
       }
 
-      public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
+      public TypeInfo getArrayType(int depth)
       {
          throw new UnreachableStatementException();
       }
 
-      public FieldInfo getDeclaredField(String name)
+      public String getName()
       {
          throw new UnreachableStatementException();
       }
 
-      public FieldInfo[] getDeclaredFields()
+      public Class getType()
       {
          throw new UnreachableStatementException();
       }
 
-      public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
+      public boolean isArray()
       {
          throw new UnreachableStatementException();
       }
 
-      public MethodInfo[] getDeclaredMethods()
+      public boolean isEnum()
       {
          throw new UnreachableStatementException();
       }
 
-      public InterfaceInfo[] getInterfaces()
+      public boolean isPrimitive()
       {
          throw new UnreachableStatementException();
       }
 
-      public String getName()
+      public Object[] newArrayInstance(int size) throws Throwable
       {
          throw new UnreachableStatementException();
       }
+   }
+   
+   static class UnknownClassInfo extends UnknownTypeInfo implements ClassInfo
+   {
+      /** The serialVersionUID */
+      private static final long serialVersionUID = 1L;
 
-      public ClassInfo getSuperclass()
+      public ConstructorInfo[] getDeclaredConstructors()
       {
          throw new UnreachableStatementException();
       }
 
-      public boolean isInterface()
+      public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
       {
          throw new UnreachableStatementException();
       }
 
-      public AnnotationValue getAnnotation(String name)
+      public FieldInfo getDeclaredField(String name)
       {
          throw new UnreachableStatementException();
       }
 
-      public AnnotationValue[] getAnnotations()
+      public FieldInfo[] getDeclaredFields()
       {
          throw new UnreachableStatementException();
       }
 
-      public boolean isAnnotationPresent(String name)
+      public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
       {
          throw new UnreachableStatementException();
       }
 
-      public String toShortString()
+      public MethodInfo[] getDeclaredMethods()
       {
          throw new UnreachableStatementException();
       }
 
-      public void toShortString(JBossStringBuilder buffer)
+      public InterfaceInfo[] getInterfaces()
       {
          throw new UnreachableStatementException();
       }
 
-      public Class getType()
+      public InterfaceInfo[] getGenericInterfaces()
       {
          throw new UnreachableStatementException();
       }
 
-      public Object convertValue(Object value) throws Throwable
+      public ClassInfo getSuperclass()
       {
          throw new UnreachableStatementException();
       }
 
-      public TypeInfo getArrayType(int depth)
+      public ClassInfo getGenericSuperclass()
       {
          throw new UnreachableStatementException();
       }
 
-      public boolean isArray()
+      public boolean isInterface()
       {
          throw new UnreachableStatementException();
       }
 
-      public boolean isEnum()
+      public AnnotationValue getAnnotation(String name)
       {
          throw new UnreachableStatementException();
       }
 
-      public boolean isPrimitive()
+      public AnnotationValue[] getAnnotations()
       {
          throw new UnreachableStatementException();
       }
 
-      public Object[] newArrayInstance(int size) throws Throwable
+      public boolean isAnnotationPresent(String name)
       {
          throw new UnreachableStatementException();
       }
 
+      public String toShortString()
+      {
+         throw new UnreachableStatementException();
+      }
+
+      public void toShortString(JBossStringBuilder buffer)
+      {
+         throw new UnreachableStatementException();
+      }
+
       public int getModifiers()
       {
          throw new UnreachableStatementException();
@@ -590,5 +669,20 @@
       {
          throw new UnreachableStatementException();
       }
+
+      public TypeInfo[] getActualTypeArguments()
+      {
+         throw new UnreachableStatementException();
+      }
+
+      public TypeInfo getOwnerType()
+      {
+         throw new UnreachableStatementException();
+      }
+
+      public ClassInfo getRawType()
+      {
+         throw new UnreachableStatementException();
+      }
    }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactory.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -21,6 +21,8 @@
 */
 package org.jboss.reflect.plugins.introspection;
 
+import java.lang.reflect.Type;
+
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 
@@ -46,4 +48,9 @@
    {
       return delegate.getTypeInfo(name, cl);
    }
+
+   public TypeInfo getTypeInfo(Type type)
+   {
+      return delegate.getTypeInfo(type);
+   }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/IntrospectionTypeInfoFactoryImpl.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -26,6 +26,8 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
@@ -43,20 +45,20 @@
 import org.jboss.reflect.plugins.MethodInfoImpl;
 import org.jboss.reflect.spi.AnnotationInfo;
 import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.ArrayInfo;
 import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.reflect.spi.InterfaceInfo;
 import org.jboss.reflect.spi.PrimitiveInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.util.collection.WeakClassCache;
+import org.jboss.util.collection.temp.WeakTypeCache;
 
 /**
  * An introspection type factory.
  *
- * FIXME: use lazy loading to avoid reading the entire class model
  * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
  */
-public class IntrospectionTypeInfoFactoryImpl extends WeakClassCache implements TypeInfoFactory, AnnotationHelper, ClassInfoHelper
+public class IntrospectionTypeInfoFactoryImpl extends WeakTypeCache<TypeInfo> implements TypeInfoFactory, AnnotationHelper, ClassInfoHelper
 {
    final static AnnotationValue[] NO_ANNOTATIONS = new AnnotationValue[0];
 
@@ -84,6 +86,19 @@
       return superType;
    }
 
+   public ClassInfo getGenericSuperClass(ClassInfoImpl classInfo)
+   {
+      Class clazz = classInfo.getType();
+      ClassInfo superType = null;
+      if (clazz.isInterface() == false)
+      {
+         Type superClazz = clazz.getGenericSuperclass();
+         if (superClazz != null)
+            superType = (ClassInfo) getTypeInfo(superClazz);
+      }
+      return superType;
+   }
+
    public AnnotationValue[] getAnnotations(Object obj)
    {
       Annotation[] annotations;
@@ -132,7 +147,7 @@
             for (int i = 0; i < constructors.length; ++i)
             {
                AnnotationValue[] annotations = getAnnotations(constructors[i]);
-               infos[i] = new ReflectConstructorInfoImpl(annotations, getTypeInfos(constructors[i].getParameterTypes()), getParameterAnnotations(constructors[i].getParameterAnnotations()), getClassInfos(constructors[i].getExceptionTypes()), constructors[i].getModifiers(), (ClassInfo) getTypeInfo(constructors[i].getDeclaringClass()));
+               infos[i] = new ReflectConstructorInfoImpl(annotations, getTypeInfos(constructors[i].getGenericParameterTypes()), getParameterAnnotations(constructors[i].getParameterAnnotations()), getClassInfos(constructors[i].getGenericExceptionTypes()), constructors[i].getModifiers(), (ClassInfo) getTypeInfo(constructors[i].getDeclaringClass()));
                infos[i].setConstructor(constructors[i]);
             }
          }
@@ -151,7 +166,7 @@
       for (int i = 0; i < fields.length; ++i)
       {
          AnnotationValue[] annotations = getAnnotations(fields[i]);
-         infos[i] = new ReflectFieldInfoImpl(annotations, fields[i].getName(), getTypeInfo(fields[i].getType()), fields[i].getModifiers(), (ClassInfo) getTypeInfo(fields[i].getDeclaringClass()));
+         infos[i] = new ReflectFieldInfoImpl(annotations, fields[i].getName(), getTypeInfo(fields[i].getGenericType()), fields[i].getModifiers(), (ClassInfo) getTypeInfo(fields[i].getDeclaringClass()));
          infos[i].setField(fields[i]);
       }
       
@@ -169,7 +184,7 @@
       for (int i = 0; i < methods.length; ++i)
       {
          AnnotationValue[] annotations = getAnnotations(methods[i]);
-         infos[i] = new ReflectMethodInfoImpl(annotations, methods[i].getName(), getTypeInfo(methods[i].getReturnType()), getTypeInfos(methods[i].getParameterTypes()), getParameterAnnotations(methods[i].getParameterAnnotations()), getClassInfos(methods[i].getExceptionTypes()), methods[i].getModifiers(), (ClassInfo) getTypeInfo(methods[i].getDeclaringClass()));
+         infos[i] = new ReflectMethodInfoImpl(annotations, methods[i].getName(), getTypeInfo(methods[i].getGenericReturnType()), getTypeInfos(methods[i].getGenericParameterTypes()), getParameterAnnotations(methods[i].getParameterAnnotations()), getClassInfos(methods[i].getGenericExceptionTypes()), methods[i].getModifiers(), (ClassInfo) getTypeInfo(methods[i].getDeclaringClass()));
          infos[i].setMethod(methods[i]);
       }
       return infos;
@@ -189,13 +204,27 @@
       return infos;
    }
 
+   public InterfaceInfo[] getGenericInterfaces(ClassInfoImpl classInfo)
+   {
+      Class clazz = classInfo.getType();
+      Type[] interfaces = clazz.getGenericInterfaces();
+      if (interfaces == null || interfaces.length == 0)
+         return null;
+
+      InterfaceInfo[] infos = new InterfaceInfo[interfaces.length];
+      for (int i = 0; i < interfaces.length; ++i)
+         infos[i] = (InterfaceInfo) getTypeInfo(interfaces[i]);
+
+      return infos;
+   }
+
    /**
     * Get the type infos for some classes
     *
     * @param classes the classes
     * @return the type infos
     */
-   public TypeInfo[] getTypeInfos(Class[] classes)
+   public TypeInfo[] getTypeInfos(Type[] classes)
    {
       if (classes == null || classes.length == 0)
          return null;
@@ -212,7 +241,7 @@
     * @param classes the classes
     * @return the class infos
     */
-   public ClassInfo[] getClassInfos(Class[] classes)
+   public ClassInfo[] getClassInfos(Type[] classes)
    {
       if (classes == null || classes.length == 0)
          return null;
@@ -232,9 +261,27 @@
       if (primitive != null)
          return primitive;
 
-      return (TypeInfo) get(clazz);
+      return get(clazz);
    }
 
+   public TypeInfo getTypeInfo(Type type)
+   {
+      if (type == null)
+         throw new IllegalArgumentException("Null type");
+
+      String name = null;
+      if (type instanceof Class)
+         name = ((Class) type).getName();
+      if (name != null)
+      {
+         TypeInfo primitive = PrimitiveInfo.valueOf(((Class) type).getName());
+         if (primitive != null)
+            return primitive;
+      }
+
+      return get(type);
+   }
+
    public TypeInfo getTypeInfo(String name, ClassLoader cl) throws ClassNotFoundException
    {
       if (name == null)
@@ -251,7 +298,7 @@
       return getTypeInfo(clazz);
    }
 
-   protected Object instantiate(Class clazz)
+   protected TypeInfo instantiate(Class<?> clazz)
    {
       ClassInfoImpl result;
       if (clazz.isArray())
@@ -295,11 +342,25 @@
       return result;
    }
 
-   protected void generate(Class clazz, Object result)
+   protected TypeInfo instantiate(ParameterizedType type)
    {
+      Class rawType = (Class) type.getRawType();
+      ClassInfo rawTypeInfo = (ClassInfo) getTypeInfo(rawType);
+      if (rawTypeInfo instanceof ArrayInfo)
+         return new ParameterizedArrayInfo(this, (ArrayInfo) rawTypeInfo, type);
+      return new ParameterizedClassInfo(this, rawTypeInfo, type);
+   }
+
+   protected void generate(Class<?> clazz, TypeInfo result)
+   {
       generateTypeInfo(clazz, (ClassInfoImpl) result);
    }
 
+   protected void generate(ParameterizedType type, TypeInfo result)
+   {
+      // Everything is lazy
+   }
+
    protected Constructor[] getDeclaredConstructors(final Class clazz)
    {
       if (System.getSecurityManager() == null)
@@ -402,4 +463,27 @@
       return annotationValues;
    }
 
+   public TypeInfo[] getActualTypeArguments(ParameterizedClassInfo classInfo)
+   {
+      ParameterizedType type = classInfo.parameterizedType;
+      Type[] types = type.getActualTypeArguments();
+      if (types == null)
+         return null;
+      
+      TypeInfo[] result = new TypeInfo[types.length];
+      for (int i = 0; i < types.length; ++i)
+         result[i] = getTypeInfo(types[i]);
+      
+      return result;
+   }
+   
+   public TypeInfo getOwnerType(ParameterizedClassInfo classInfo)
+   {
+      ParameterizedType type = classInfo.parameterizedType;
+      Type owner = type.getOwnerType();
+      if (owner == null)
+         return null;
+      
+      return getTypeInfo(owner);
+   }
 }

Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedArrayInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedArrayInfo.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedArrayInfo.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.introspection;
+
+import java.lang.reflect.ParameterizedType;
+
+import org.jboss.reflect.plugins.ClassInfoHelper;
+import org.jboss.reflect.spi.ArrayInfo;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * ParameterizedArrayInfo.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParameterizedArrayInfo extends ParameterizedClassInfo implements ArrayInfo
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -2126867826240682161L;
+
+   /**
+    * Create a new ParameterizedArrayInfo.
+    * 
+    * @param helper the helper
+    * @param delegate the raw array info
+    * @param parameterizedType the parameterized  type
+    */
+   public ParameterizedArrayInfo(ClassInfoHelper helper, ArrayInfo delegate, ParameterizedType parameterizedType)
+   {
+      super(helper, delegate, parameterizedType);
+   }
+
+   public TypeInfo getComponentType()
+   {
+      return ((ArrayInfo) delegate).getComponentType();
+   }
+}

Added: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,251 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.reflect.plugins.introspection;
+
+import java.lang.reflect.ParameterizedType;
+
+import org.jboss.reflect.plugins.ClassInfoHelper;
+import org.jboss.reflect.plugins.ClassInfoImpl;
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * ParameterizedClassInfo.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParameterizedClassInfo extends JBossObject implements ClassInfo, InterfaceInfo
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -8739806147734002603L;
+   
+   /** The helper */
+   protected ClassInfoHelper helper;
+   
+   /** The raw class info */
+   protected ClassInfo delegate;
+   
+   /** The parameterized type */
+   ParameterizedType parameterizedType;
+   
+   /** The owner type */
+   private TypeInfo ownerType = ClassInfoImpl.UNKNOWN_TYPE;
+   
+   /** The type arguments */
+   private TypeInfo[] typeArguments = ClassInfoImpl.UNKNOWN_TYPES;
+   
+   /**
+    * Create a new ParameterizedClassInfo.
+    *
+    * @param helper the helper
+    * @param delegate the raw array info
+    * @param parameterizedType the parameterized  type
+    */
+   public ParameterizedClassInfo(ClassInfoHelper helper, ClassInfo delegate, ParameterizedType parameterizedType)
+   {
+      this.helper = helper;
+      this.delegate = delegate;
+      this.parameterizedType = parameterizedType;
+   }
+
+   public ConstructorInfo getDeclaredConstructor(TypeInfo[] parameters)
+   {
+      return delegate.getDeclaredConstructor(parameters);
+   }
+
+   public ConstructorInfo[] getDeclaredConstructors()
+   {
+      return delegate.getDeclaredConstructors();
+   }
+
+   public FieldInfo getDeclaredField(String name)
+   {
+      return delegate.getDeclaredField(name);
+   }
+
+   public FieldInfo[] getDeclaredFields()
+   {
+      return delegate.getDeclaredFields();
+   }
+
+   public MethodInfo getDeclaredMethod(String name, TypeInfo[] parameters)
+   {
+      return delegate.getDeclaredMethod(name, parameters);
+   }
+
+   public MethodInfo[] getDeclaredMethods()
+   {
+      return delegate.getDeclaredMethods();
+   }
+
+   public InterfaceInfo[] getGenericInterfaces()
+   {
+      return delegate.getGenericInterfaces();
+   }
+
+   public ClassInfo getGenericSuperclass()
+   {
+      return delegate.getGenericSuperclass();
+   }
+
+   public InterfaceInfo[] getInterfaces()
+   {
+      return delegate.getInterfaces();
+   }
+
+   public String getName()
+   {
+      return delegate.getName();
+   }
+
+   public ClassInfo getSuperclass()
+   {
+      return delegate.getSuperclass();
+   }
+
+   public boolean isInterface()
+   {
+      return delegate.isInterface();
+   }
+
+   public AnnotationValue getAnnotation(String name)
+   {
+      return delegate.getAnnotation(name);
+   }
+
+   public AnnotationValue[] getAnnotations()
+   {
+      return delegate.getAnnotations();
+   }
+
+   public boolean isAnnotationPresent(String name)
+   {
+      return delegate.isAnnotationPresent(name);
+   }
+
+   public int getModifiers()
+   {
+      return delegate.getModifiers();
+   }
+
+   public boolean isPublic()
+   {
+      return delegate.isPublic();
+   }
+
+   public boolean isStatic()
+   {
+      return delegate.isStatic();
+   }
+
+   public Object convertValue(Object value) throws Throwable
+   {
+      return delegate.convertValue(value);
+   }
+
+   public TypeInfo getArrayType(int depth)
+   {
+      return delegate.getArrayType(depth);
+   }
+   
+   public Class getType()
+   {
+      return delegate.getType();
+   }
+
+   public boolean isArray()
+   {
+      return delegate.isArray();
+   }
+
+   public boolean isEnum()
+   {
+      return delegate.isEnum();
+   }
+
+   public boolean isPrimitive()
+   {
+      return delegate.isPrimitive();
+   }
+
+   public Object[] newArrayInstance(int size) throws Throwable
+   {
+      return delegate.newArrayInstance(size);
+   }
+
+   public TypeInfo[] getActualTypeArguments()
+   {
+      if (typeArguments == ClassInfoImpl.UNKNOWN_TYPES)
+         typeArguments = helper.getActualTypeArguments(this);
+      return typeArguments;
+   }
+
+   public TypeInfo getOwnerType()
+   {
+      if (ownerType == ClassInfoImpl.UNKNOWN_TYPE)
+         ownerType = helper.getOwnerType(this);
+      return ownerType;
+   }
+
+   public ClassInfo getRawType()
+   {
+      return delegate;
+   }
+
+   protected int getHashCode()
+   {
+      return delegate.hashCode();
+   }
+
+   public boolean equals(Object obj)
+   {
+      if (obj == this)
+         return true;
+      
+      if (obj == null || obj instanceof ClassInfo == false)
+         return false;
+      
+      ClassInfo other = (ClassInfo) obj;
+      if (other instanceof ParameterizedClassInfo)
+         other = ((ParameterizedClassInfo) other).delegate;
+      
+      return delegate.equals(other);
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(parameterizedType);
+   }
+
+   protected void toString(JBossStringBuilder buffer)
+   {
+      buffer.append(parameterizedType);
+   }
+}

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistArrayInfoImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistArrayInfoImpl.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistArrayInfoImpl.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -23,7 +23,6 @@
 
 import javassist.CtClass;
 
-import org.jboss.reflect.spi.AnnotatedInfo;
 import org.jboss.reflect.spi.AnnotationValue;
 import org.jboss.reflect.spi.ArrayInfo;
 import org.jboss.reflect.spi.TypeInfo;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -156,6 +156,12 @@
       }
    }
 
+   public ClassInfo getGenericSuperclass()
+   {
+      // TODO getGenericSuperclass
+      throw new org.jboss.util.NotImplementedException("getGenericSuperclass");
+   }
+
    public InterfaceInfo[] getInterfaces()
    {
       try
@@ -174,6 +180,12 @@
       }
    }
 
+   public InterfaceInfo[] getGenericInterfaces()
+   {
+      // TODO getGenericInterfaces
+      throw new org.jboss.util.NotImplementedException("getGenericInterfaces");
+   }
+
    public ConstructorInfo[] getDeclaredConstructors()
    {
       if (constructorArray == null)
@@ -542,4 +554,19 @@
       }
    }
 
+   public TypeInfo[] getActualTypeArguments()
+   {
+      return null;
+   }
+
+   public TypeInfo getOwnerType()
+   {
+      return null;
+   }
+
+   public ClassInfo getRawType()
+   {
+      return this;
+   }
+
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactory.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactory.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -21,6 +21,8 @@
 */
 package org.jboss.reflect.plugins.javassist;
 
+import java.lang.reflect.Type;
+
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.reflect.spi.TypeInfoFactory;
 
@@ -46,4 +48,10 @@
    {
       return delegate.getTypeInfo(name, cl);
    }
+   
+   public TypeInfo getTypeInfo(Type type)
+   {
+      return delegate.getTypeInfo(type);
+   }
+
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -22,6 +22,7 @@
 package org.jboss.reflect.plugins.javassist;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 
 import javassist.ClassPool;
 import javassist.CtClass;
@@ -273,6 +274,15 @@
       return getTypeInfo(clazz);
    }
    
+   public TypeInfo getTypeInfo(Type type)
+   {
+      if (type instanceof Class)
+         return getTypeInfo((Class) type);
+
+      // TODO getTypeInfo
+      throw new org.jboss.util.NotImplementedException("getTypeInfo");
+   }
+
    public AnnotationValue[] getAnnotations(Object obj)
    {
       try

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/ClassInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/ClassInfo.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/ClassInfo.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -51,6 +51,13 @@
    InterfaceInfo[] getInterfaces();
    
    /**
+    * Get the generic interfaces
+    *
+    * @return the generic interfaces
+    */
+   InterfaceInfo[] getGenericInterfaces();
+   
+   /**
     * Get the declared method
     * 
     * @param name the method name
@@ -102,4 +109,32 @@
     * @return the super class
     */
    ClassInfo getSuperclass();
+
+   /**
+    * Get the generic super class
+    * 
+    * @return the super class
+    */
+   ClassInfo getGenericSuperclass();
+   
+   /**
+    * Get the actual type parameters
+    * 
+    * @return the type parameters
+    */
+   TypeInfo[] getActualTypeArguments();
+   
+   /**
+    * Get the raw type
+    * 
+    * @return the raw type
+    */
+   ClassInfo getRawType();
+   
+   /**
+    * Get the owner type
+    * 
+    * @return the owner type
+    */
+   TypeInfo getOwnerType();
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfoFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfoFactory.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfoFactory.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -21,6 +21,8 @@
 */
 package org.jboss.reflect.spi;
 
+import java.lang.reflect.Type;
+
 /**
  * A type info factory.
  *
@@ -45,4 +47,12 @@
     * @return the type info
     */
    TypeInfo getTypeInfo(Class clazz);
+
+   /**
+    * Get a type info
+    * 
+    * @param type the type
+    * @return the type info
+    */
+   TypeInfo getTypeInfo(Type type);
 }

Added: projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/FIXME
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/FIXME	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/FIXME	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1 @@
+THESE CLASSES NEED TO BE MOVED TO COMMON WHEN IT SUPPORTS JDK5 + JBOSS RETRO
\ No newline at end of file

Added: projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/WeakTypeCache.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/WeakTypeCache.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/WeakTypeCache.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,283 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.util.collection.temp;
+
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * A weak class cache that instantiates does not a hold a
+ * strong reference to either the classloader or class.<p>
+ * 
+ * It creates the class specific data in two stages
+ * to avoid recursion.<p>
+ * 
+ * instantiate - creates the data<br>
+ * generate - fills in the details
+ *
+ * @param <T> the cached type
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ */
+public abstract class WeakTypeCache<T>
+{
+   /** The cache */
+   private Map<ClassLoader, Map<String, T>> cache = new WeakHashMap<ClassLoader, Map<String, T>>(); 
+   
+   /**
+    * Get the information for a type
+    * 
+    * @param type the type
+    * @return the info
+    */
+   public T get(Type type)
+   {
+      if (type == null)
+         throw new IllegalArgumentException("Null type");
+
+      if (type instanceof ParameterizedType)
+         return getParameterizedType((ParameterizedType) type);
+      else if (type instanceof Class)
+         return getClass((Class<?>) type);
+      else if (type instanceof TypeVariable)
+         return getTypeVariable((TypeVariable) type);
+      else if (type instanceof GenericArrayType)
+         return getGenericArrayType((GenericArrayType) type);
+      else
+         throw new UnsupportedOperationException("Unknown type: " + type + " class=" + type.getClass());
+   }
+   
+   /**
+    * Get the information for a class
+    * 
+    * @param name the name
+    * @param cl the classloader
+    * @return the info
+    * @throws ClassNotFoundException when the class cannot be found
+    */
+   public T get(String name, ClassLoader cl) throws ClassNotFoundException
+   {
+      if (name == null)
+         throw new IllegalArgumentException("Null name");
+      if (cl == null)
+         throw new IllegalArgumentException("Null classloader");
+
+      Class<?> clazz = cl.loadClass(name);
+      return get(clazz);
+   }
+   
+   /**
+    * Instantiate for a class
+    * 
+    * @param clazz the class
+    * @return the result
+    */
+   protected abstract T instantiate(Class<?> clazz);
+   
+   /**
+    * Fill in the result
+    * 
+    * @param clazz the class
+    * @param result the result
+    */
+   protected abstract void generate(Class<?> clazz, T result);
+   
+   /**
+    * Instantiate for a parameterized type
+    * 
+    * @param type the parameterized type
+    * @return the result
+    */
+   protected abstract T instantiate(ParameterizedType type);
+   
+   /**
+    * Fill in the result
+    * 
+    * @param type the parameterized type
+    * @param result the result
+    */
+   protected abstract void generate(ParameterizedType type, T result);
+
+   /**
+    * Get the information for a parameterized type
+    * 
+    * @param type the paremeterized type
+    * @return the info
+    */
+   private T getParameterizedType(ParameterizedType type)
+   {
+      // First check if we already have it
+      T result = peek(type);
+      if (result != null)
+         return result;
+      
+      // Instantiate
+      result = instantiate(type);
+
+      // Put the perlimanary result into the cache
+      put(type, result);
+
+      // Generate the details
+      generate(type, result);
+      
+      return result;
+   }
+
+   /**
+    * Get the information for a type variable
+    * 
+    * @param type the type variable
+    * @return the info
+    */
+   private T getTypeVariable(TypeVariable type)
+   {
+      // TODO improve this
+      return get(type.getBounds()[0]);
+   }
+
+   /**
+    * Get the information for an array type
+    * 
+    * @param type the array type
+    * @return the info
+    */
+   private T getGenericArrayType(GenericArrayType type)
+   {
+      // TODO this needs implementing properly
+      return get(Object[].class);
+   }
+
+   /**
+    * Peek into the cache
+    * 
+    * @param type the type
+    * @return the value
+    */
+   private T peek(ParameterizedType type)
+   {
+      Class<?> rawType = (Class<?>) type.getRawType();
+      Map<String, T> classLoaderCache = getClassLoaderCache(rawType.getClassLoader());
+      
+      synchronized (classLoaderCache)
+      {
+         return classLoaderCache.get(type.toString());
+      }
+   }
+
+   /**
+    * Put a result into the cache
+    * 
+    * @param clazz the class
+    * @param result the value
+    */
+   private void put(ParameterizedType type, T result)
+   {
+      Class<?> rawType = (Class<?>) type.getRawType();
+      Map<String, T> classLoaderCache = getClassLoaderCache(rawType.getClassLoader());
+
+      synchronized (classLoaderCache)
+      {
+         // TODO something better than toString()?
+         classLoaderCache.put(type.toString(), result);
+      }
+   }
+
+   /**
+    * Get the information for a class
+    * 
+    * @param clazz the class
+    * @return the info
+    */
+   private T getClass(Class<?> clazz)
+   {
+      // First check if we already have it
+      T result = peek(clazz);
+      if (result != null)
+         return result;
+
+      // Instantiate
+      result = instantiate(clazz);
+
+      // Put the perlimanary result into the cache
+      put(clazz, result);
+
+      // Generate the details
+      generate(clazz, result);
+      
+      return result;
+   }
+
+   /**
+    * Peek into the cache
+    * 
+    * @param clazz the class
+    * @return the value
+    */
+   private T peek(Class<?> clazz)
+   {
+      Map<String, T> classLoaderCache = getClassLoaderCache(clazz.getClassLoader());
+
+      synchronized (classLoaderCache)
+      {
+         return classLoaderCache.get(clazz.getName());
+      }
+   }
+
+   /**
+    * Put a result into the cache
+    * 
+    * @param clazz the class
+    * @param result the value
+    */
+   private void put(Class<?> clazz, T result)
+   {
+      Map<String, T> classLoaderCache = getClassLoaderCache(clazz.getClassLoader());
+
+      synchronized (classLoaderCache)
+      {
+         classLoaderCache.put(clazz.getName(), result);
+      }
+   }
+   
+   /**
+    * Get the cache for the classloader
+    * 
+    * @param cl the classloader
+    * @return the map
+    */
+   private Map<String, T> getClassLoaderCache(ClassLoader cl)
+   {
+      synchronized (cache)
+      {
+         Map<String, T> result = cache.get(cl);
+         if (result == null)
+         {
+            result = new WeakValueHashMap<String, T>();
+            cache.put(cl, result);
+         }
+         return result;
+      }
+   }
+}

Added: projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/WeakValueHashMap.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/WeakValueHashMap.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/util/collection/temp/WeakValueHashMap.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,293 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.util.collection.temp;
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * This Map will remove entries when the value in the map has been
+ * cleaned from garbage collection
+ *
+ * @param <K> the key type
+ * @param <V> the value type
+ * @author  <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author  <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @version <tt>$Revision: 1958 $</tt>
+ */
+public class WeakValueHashMap<K, V> extends AbstractMap<K, V> 
+{
+   /** Hash table mapping keys to weak values */
+   private Map<K, WeakValueRef<K, V>> hash;
+
+   /** Reference queue for cleared WeakKeys */
+   private ReferenceQueue<V> queue = new ReferenceQueue<V>();
+
+   /**
+    * Constructs a new, empty <code>WeakHashMap</code> with the given
+    * initial capacity and the given load factor.
+    *
+    * @param  initialCapacity  The initial capacity of the
+    *                          <code>WeakHashMap</code>
+    *
+    * @param  loadFactor       The load factor of the <code>WeakHashMap</code>
+    *
+    * @throws IllegalArgumentException  If the initial capacity is less than
+    *                                   zero, or if the load factor is
+    *                                   nonpositive
+    */
+   public WeakValueHashMap(int initialCapacity, float loadFactor)
+   {
+      hash = new HashMap<K, WeakValueRef<K, V>>(initialCapacity, loadFactor);
+   }
+
+   /**
+    * Constructs a new, empty <code>WeakHashMap</code> with the given
+    * initial capacity and the default load factor, which is
+    * <code>0.75</code>.
+    *
+    * @param  initialCapacity  The initial capacity of the
+    *                          <code>WeakHashMap</code>
+    *
+    * @throws IllegalArgumentException  If the initial capacity is less than
+    *                                   zero
+    */
+   public WeakValueHashMap(int initialCapacity)
+   {
+      hash = new HashMap<K, WeakValueRef<K, V>>(initialCapacity);
+   }
+
+   /**
+    * Constructs a new, empty <code>WeakHashMap</code> with the default
+    * initial capacity and the default load factor, which is
+    * <code>0.75</code>.
+    */
+   public WeakValueHashMap()
+   {
+      hash = new HashMap<K, WeakValueRef<K, V>>();
+   }
+
+   /**
+    * Constructs a new <code>WeakHashMap</code> with the same mappings as the
+    * specified <tt>Map</tt>.  The <code>WeakHashMap</code> is created with an
+    * initial capacity of twice the number of mappings in the specified map
+    * or 11 (whichever is greater), and a default load factor, which is
+    * <tt>0.75</tt>.
+    *
+    * @param   t the map whose mappings are to be placed in this map.
+    * @since    1.3
+    */
+   public WeakValueHashMap(Map<K, V> t)
+   {
+      this(Math.max(2*t.size(), 11), 0.75f);
+      putAll(t);
+   }
+
+   @Override
+   public int size()
+   {
+      processQueue();
+      return hash.size();
+   }
+
+   @Override
+   public boolean containsKey(Object key)
+   {
+      processQueue();
+      return hash.containsKey(key);
+   }
+
+   @Override
+   public V get(Object key)
+   {
+      processQueue();
+      WeakValueRef<K, V> ref = hash.get(key);
+      if (ref != null)
+         return ref.get();
+      return null;
+   }
+
+   @Override
+   public V put(K key, V value) 
+   {
+      processQueue();
+      WeakValueRef<K, V> ref = WeakValueRef.create(key, value, queue);
+      WeakValueRef<K, V> result = hash.put(key, ref);
+      if (result != null)
+         return result.get();
+      return null;
+   }
+
+   @Override
+   public V remove(Object key) 
+   {
+      processQueue();
+      WeakValueRef<K, V> result = hash.remove(key);
+      if (result != null)
+         return result.get();
+      return null;
+   }
+   
+   @Override
+   public Set<Entry<K,V>> entrySet() 
+   { 
+      processQueue();
+      return new EntrySet();
+   }
+
+   @Override
+   public void clear()
+   {
+      processQueue();
+      hash.clear();
+   }
+   
+   /**
+    * Remove all entries whose values have been discarded.  
+    */
+   @SuppressWarnings("unchecked")
+   private void processQueue()
+   {
+      WeakValueRef<K, V> ref = (WeakValueRef<K, V>) queue.poll();
+      while (ref != null)
+      {
+         // only remove if it is the *exact* same WeakValueRef
+         if (ref == hash.get(ref.key))
+            hash.remove(ref.key);
+         
+         ref = (WeakValueRef<K, V>) queue.poll();
+      }
+   }
+   
+   /**
+    * EntrySet.
+    */
+   private class EntrySet extends AbstractSet<Entry<K, V>>
+   {
+      @Override
+      public Iterator<Entry<K, V>> iterator()
+      {
+         return new EntrySetIterator(hash.entrySet().iterator());
+      }
+
+      @Override
+      public int size()
+      {
+         return WeakValueHashMap.this.size();
+      }
+   }
+   
+   /**
+    * EntrySet iterator
+    */
+   private class EntrySetIterator implements Iterator<Entry<K, V>>
+   {
+      /** The delegate */
+      private Iterator<Entry<K, WeakValueRef<K, V>>> delegate;
+      
+      /**
+       * Create a new EntrySetIterator.
+       * 
+       * @param delegate the delegate
+       */
+      public EntrySetIterator(Iterator<Entry<K, WeakValueRef<K, V>>> delegate)
+      {
+         this.delegate = delegate;
+      }
+
+      public boolean hasNext()
+      {
+         return delegate.hasNext();
+      }
+
+      public Entry<K, V> next()
+      {
+         Entry<K, WeakValueRef<K, V>> next = delegate.next();
+         return next.getValue();
+      }
+
+      public void remove()
+      {
+         throw new UnsupportedOperationException("remove");
+      }
+   }
+   
+   /**
+    * WeakValueRef.
+    */
+   private static class WeakValueRef<K, V> extends WeakReference<V> implements Map.Entry<K, V>
+   {
+      /** The key */
+      public K key;
+
+      /**
+       * Safely create a new WeakValueRef
+       * 
+       * @param key the key
+       * @param val the value
+       * @param q the reference queue
+       * @return the reference or null if the value is null
+       */
+      private static <K, V> WeakValueRef<K, V> create(K key, V val, ReferenceQueue<V> q)
+      {
+         if (val == null)
+            return null;
+         else 
+            return new WeakValueRef<K, V>(key, val, q);
+      }
+
+      /**
+       * Create a new WeakValueRef.
+       * 
+       * @param key the key
+       * @param val the value
+       * @param q the reference queue
+       */
+      private WeakValueRef(K key, V val, ReferenceQueue<V> q)
+      {
+         super(val, q);
+         this.key = key;
+      }
+
+      public K getKey()
+      {
+         return key;
+      }
+
+      public V getValue()
+      {
+         return get();
+      }
+
+      public V setValue(V value)
+      {
+         throw new UnsupportedOperationException("setValue");
+      }
+   }
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericClass.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericClass.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericClass.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericClass
+ * 
+ * @param <T> the generic type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericClass<T>
+{
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericConstructorsClass.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericConstructorsClass.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericConstructorsClass.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericConstructors
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericConstructorsClass
+{
+   ClassInfoGenericConstructorsClass(ClassInfoGenericClass<String> p1) {};
+   ClassInfoGenericConstructorsClass(ClassInfoGenericClass<String> p1, ClassInfoGenericClass<ClassInfoEmptyClass> p2) {};
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericFieldsClass.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericFieldsClass.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericFieldsClass.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericField
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericFieldsClass
+{
+   ClassInfoGenericClass<String> fieldString;
+   ClassInfoGenericClass<ClassInfoEmptyClass> fieldClass;
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericFieldsInterface.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericFieldsInterface.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericFieldsInterface.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericFieldsInterface
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ClassInfoGenericFieldsInterface
+{
+   ClassInfoGenericClass<String> fieldString = null;
+   ClassInfoGenericClass<ClassInfoEmptyClass> fieldClass = null;
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericInterface.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericInterface.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericInterface.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericInterface
+ * 
+ * @param <T> the generic type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ClassInfoGenericInterface<T>
+{
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericMethodsClass.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericMethodsClass.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericMethodsClass.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericMethods
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericMethodsClass
+{
+   void doSomething(ClassInfoGenericClass<String> p1) {};
+   void doSomething(ClassInfoGenericClass<String> p1, ClassInfoGenericClass<ClassInfoEmptyClass> p2) {};
+   ClassInfoGenericClass<String> doSomething2(ClassInfoGenericClass<Integer> p1) {return null;};
+   ClassInfoGenericClass<String> doSomething2(ClassInfoGenericClass<Integer> p1, ClassInfoGenericClass<ClassInfoEmptyClass> p2) {return null;};
+   ClassInfoGenericClass<ClassInfoEmptyClass> doSomething3(ClassInfoGenericClass<Integer> p1) {return null;};
+   ClassInfoGenericClass<ClassInfoEmptyClass> doSomething3(ClassInfoGenericClass<Integer> p1, ClassInfoGenericClass<ClassInfoEmptyClass> p2) {return null;};
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericMethodsInterface.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericMethodsInterface.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericMethodsInterface.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericMethods
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ClassInfoGenericMethodsInterface
+{
+   void doSomething(ClassInfoGenericClass<String> p1);
+   void doSomething(ClassInfoGenericClass<String> p1, ClassInfoGenericClass<ClassInfoEmptyClass> p2);
+   ClassInfoGenericClass<String> doSomething2(ClassInfoGenericClass<Integer> p1);
+   ClassInfoGenericClass<String> doSomething2(ClassInfoGenericClass<Integer> p1, ClassInfoGenericClass<ClassInfoEmptyClass> p2);
+   ClassInfoGenericClass<ClassInfoEmptyClass> doSomething3(ClassInfoGenericClass<Integer> p1);
+   ClassInfoGenericClass<ClassInfoEmptyClass> doSomething3(ClassInfoGenericClass<Integer> p1, ClassInfoGenericClass<ClassInfoEmptyClass> p2);
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassEmptyClass.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassEmptyClass.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassEmptyClass.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoSuperClass
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericSuperClassEmptyClass extends ClassInfoGenericClass<ClassInfoEmptyClass>
+{
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassString.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassString.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassString.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoSuperClass
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericSuperClassString extends ClassInfoGenericClass<String>
+{
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceEmptyClass.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceEmptyClass.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceEmptyClass.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericSuperInterfaceEmptyClass.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericSuperInterfaceEmptyClass implements ClassInfoGenericInterface<ClassInfoEmptyClass>
+{
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceString.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceString.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceString.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.support;
+
+/**
+ * ClassInfoGenericSuperInterfaceString.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericSuperInterfaceString implements ClassInfoGenericInterface<String>
+{
+}

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/AbstractClassInfoTest.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -26,6 +26,7 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -187,7 +188,7 @@
       Set<FieldInfo> expected = new HashSet<FieldInfo>();
       for (Field field : clazz.getDeclaredFields())
       {
-         TypeInfo type = factory.getTypeInfo(field.getType());
+         TypeInfo type = factory.getTypeInfo(field.getGenericType());
          FieldInfo f = new FieldInfoImpl(null, field.getName(), type, field.getModifiers(), classInfo);
          expected.add(f);
       }
@@ -218,8 +219,8 @@
       
       FieldInfo fieldInfo = classInfo.getDeclaredField(field.getName());
       assertNotNull(field.getName(), fieldInfo);
-      TypeInfo type = factory.getTypeInfo(field.getType());
-      assertEquals(type, fieldInfo.getType());
+      TypeInfo type = factory.getTypeInfo(field.getGenericType());
+      assertTypeEquals(field.getName(), type, fieldInfo.getType());
       assertEquals(classInfo, fieldInfo.getDeclaringClass());
       assertEquals(field.getModifiers(), fieldInfo.getModifiers());
       assertFieldAnnotations(field, fieldInfo);
@@ -266,24 +267,24 @@
 
       TypeInfoFactory factory = getTypeInfoFactory();
       
-      Class[] paramClasses = method.getParameterTypes();
+      Type[] paramClasses = method.getGenericParameterTypes();
       TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
       for (int i = 0; i < paramClasses.length; ++i)
          paramTypes[i] = factory.getTypeInfo(paramClasses[i]);
       MethodInfo methodInfo = classInfo.getDeclaredMethod(method.getName(), paramTypes);
       assertNotNull(method.getName(), methodInfo);
-      TypeInfo returnType = factory.getTypeInfo(method.getReturnType());
+      TypeInfo returnType = factory.getTypeInfo(method.getGenericReturnType());
       TypeInfo[] actualParamTypes = methodInfo.getParameterTypes();
       for (int i = 0; i < paramTypes.length; ++i)
-         assertEquals(paramTypes[i], actualParamTypes[i]);
+         assertTypeEquals(method.getName() + " param" + i, paramTypes[i], actualParamTypes[i]);
       Class[] exceptionClasses = method.getExceptionTypes();
       TypeInfo[] expectedExceptionTypes = new TypeInfo[exceptionClasses.length];
       for (int i = 0; i < exceptionClasses.length; ++i)
          expectedExceptionTypes[i] = factory.getTypeInfo(exceptionClasses[i]);
       TypeInfo[] actualExceptionTypes = methodInfo.getExceptionTypes();
       for (int i = 0; i < exceptionClasses.length; ++i)
-         assertEquals(expectedExceptionTypes[i], actualExceptionTypes[i]);
-      assertEquals(returnType, methodInfo.getReturnType());
+         assertTypeEquals(method.getName() + " exception" + i, expectedExceptionTypes[i], actualExceptionTypes[i]);
+      assertTypeEquals(method.getName() + " returnType", returnType, methodInfo.getReturnType());
       assertEquals(classInfo, methodInfo.getDeclaringClass());
       assertEquals(method.getModifiers(), methodInfo.getModifiers());
       assertMethodAnnotations(method, methodInfo);
@@ -330,7 +331,7 @@
 
       TypeInfoFactory factory = getTypeInfoFactory();
       
-      Class[] paramClasses = constructor.getParameterTypes();
+      Type[] paramClasses = constructor.getGenericParameterTypes();
       TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
       for (int i = 0; i < paramClasses.length; ++i)
          paramTypes[i] = factory.getTypeInfo(paramClasses[i]);
@@ -338,14 +339,14 @@
       assertNotNull(constructorInfo);
       TypeInfo[] actualParamTypes = constructorInfo.getParameterTypes();
       for (int i = 0; i < paramTypes.length; ++i)
-         assertEquals(paramTypes[i], actualParamTypes[i]);
+         assertTypeEquals(clazz + " constructorParameter" + i, paramTypes[i], actualParamTypes[i]);
       Class[] exceptionClasses = constructor.getExceptionTypes();
       TypeInfo[] expectedExceptionTypes = new TypeInfo[exceptionClasses.length];
       for (int i = 0; i < exceptionClasses.length; ++i)
          expectedExceptionTypes[i] = factory.getTypeInfo(exceptionClasses[i]);
       TypeInfo[] actualExceptionTypes = constructorInfo.getExceptionTypes();
       for (int i = 0; i < exceptionClasses.length; ++i)
-         assertEquals(expectedExceptionTypes[i], actualExceptionTypes[i]);
+         assertTypeEquals(clazz + " constructorException" + i, expectedExceptionTypes[i], actualExceptionTypes[i]);
       assertEquals(classInfo, constructorInfo.getDeclaringClass());
       assertEquals(constructor.getModifiers(), constructorInfo.getModifiers());
       assertConstructorAnnotations(constructor, constructorInfo);
@@ -476,6 +477,30 @@
       }
       return expected;
    }
+
+   protected void assertTypeEquals(String context, TypeInfo expected, TypeInfo actual) throws Exception
+   {
+      assertEquals(expected, actual);
+      if (expected instanceof ClassInfo)
+      {
+         ClassInfo expectedClassInfo = (ClassInfo) expected;
+         ClassInfo actualClassInfo = (ClassInfo) actual;
+         assertEquals(context, expectedClassInfo.getOwnerType(), actualClassInfo.getOwnerType());
+         assertEquals(context, expectedClassInfo.getRawType(), actualClassInfo.getRawType());
+         TypeInfo[] expectedTypeArgs = expectedClassInfo.getActualTypeArguments();
+         TypeInfo[] actualTypeArgs = expectedClassInfo.getActualTypeArguments();
+         if (expectedTypeArgs == null)
+            assertNull(context, actualTypeArgs);
+         else
+         {
+            assertNotNull(context, actualTypeArgs);
+            getLog().debug("Checking type args for " + context + " expected: " + Arrays.asList(expectedTypeArgs) + " actual: " + Arrays.asList(actualTypeArgs));
+            assertEquals(expectedTypeArgs.length, actualTypeArgs.length);
+            for (int i = 0; i < expectedTypeArgs.length; ++i)
+               assertTypeEquals(context + "arg" + i, expectedTypeArgs[i], actualTypeArgs[i]);
+         }
+      }
+   }
    
    protected abstract TypeInfoFactory getTypeInfoFactory();
    

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoGenericClassTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoGenericClassTest.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoGenericClassTest.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,145 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.test;
+
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+
+import org.jboss.reflect.plugins.ClassInfoImpl;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.test.classinfo.support.ClassInfoEmptyClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericConstructorsClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericFieldsClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericInterface;
+import org.jboss.test.classinfo.support.ClassInfoGenericMethodsClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperClassEmptyClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperClassString;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperInterfaceEmptyClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperInterfaceString;
+
+
+/**
+ * ClassInfoGenericClassTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ClassInfoGenericClassTest extends AbstractClassInfoTest
+{
+   public ClassInfoGenericClassTest(String name)
+   {
+      super(name);
+   }
+   
+   public void testGenericSuperClassString()
+   {
+      testGenericSuperClass(ClassInfoGenericSuperClassString.class, ClassInfoGenericClass.class, new Class[] { String.class });
+   }
+   
+   public void testGenericSuperClassEmptyClass()
+   {
+      testGenericSuperClass(ClassInfoGenericSuperClassEmptyClass.class, ClassInfoGenericClass.class, new Class[] { ClassInfoEmptyClass.class });
+   }
+   
+   public void testGenericSuperInterfaceString()
+   {
+      testGenericSuperInterface(ClassInfoGenericSuperInterfaceString.class, ClassInfoGenericInterface.class, new Class[] { String.class });
+   }
+   
+   public void testGenericSuperInterfaceEmptyClass()
+   {
+      testGenericSuperInterface(ClassInfoGenericSuperInterfaceEmptyClass.class, ClassInfoGenericInterface.class, new Class[] { ClassInfoEmptyClass.class });
+   }
+   
+   public void testGenericSuperClass(Class clazz, Class genericClass, Class[] genericTypes)
+   {
+      TypeInfoFactory factory = getTypeInfoFactory();
+      ClassInfo typeInfo = (ClassInfo) factory.getTypeInfo(clazz);
+      ClassInfo superClassInfo = typeInfo.getGenericSuperclass();
+      ClassInfo genericClassInfo = (ClassInfo) factory.getTypeInfo(genericClass);
+      getLog().debug("Checking superClass: " + genericClass + " against " + superClassInfo);
+      assertEquals(genericClassInfo, superClassInfo);
+
+      TypeInfo[] types = new TypeInfo[genericTypes.length];
+      for (int i = 0; i < types.length; ++i)
+         types[i] = factory.getTypeInfo(genericTypes[i]);
+      TypeInfo[] actualTypes = superClassInfo.getActualTypeArguments();
+      getLog().debug("Checking superClass types: " + Arrays.asList(genericTypes) + " against " + Arrays.asList(actualTypes));
+      assertEquals(types.length, actualTypes.length);
+      for (int i = 0; i < types.length; ++i)
+         assertEquals(types[i], actualTypes[i]);
+   }
+   
+   public void testGenericSuperInterface(Class clazz, Class genericClass, Class[] genericTypes)
+   {
+      TypeInfoFactory factory = getTypeInfoFactory();
+      ClassInfo typeInfo = (ClassInfo) factory.getTypeInfo(clazz);
+      InterfaceInfo[] superInterfaces = typeInfo.getGenericInterfaces();
+      assertNotNull(superInterfaces);
+      assertEquals(1, superInterfaces.length);
+      InterfaceInfo superInterface = superInterfaces[0]; 
+      getLog().debug("Checking superInterface: " + genericClass + " against " + superInterface);
+      ClassInfo genericClassInfo = (ClassInfo) factory.getTypeInfo(genericClass);
+      assertEquals(genericClassInfo, superInterface);
+
+      TypeInfo[] types = new TypeInfo[genericTypes.length];
+      for (int i = 0; i < types.length; ++i)
+         types[i] = factory.getTypeInfo(genericTypes[i]);
+      TypeInfo[] actualTypes = superInterface.getActualTypeArguments();
+      getLog().debug("Checking superInterface types: " + Arrays.asList(genericTypes) + " against " + Arrays.asList(actualTypes));
+      assertEquals(types.length, actualTypes.length);
+      for (int i = 0; i < types.length; ++i)
+         assertEquals(types[i], actualTypes[i]);
+   }
+
+   public void testGenericMethodsClass() throws Throwable
+   {
+      testGenericClass(ClassInfoGenericMethodsClass.class);
+   }
+
+   public void testGenericConstructorsClass() throws Throwable
+   {
+      testGenericClass(ClassInfoGenericConstructorsClass.class);
+   }
+   
+   public void testGenericFieldsClass() throws Throwable
+   {
+      testGenericClass(ClassInfoGenericFieldsClass.class);
+   }
+   
+   private void testGenericClass(Class clazz) throws Throwable
+   {
+      ClassInfoImpl expected = new ClassInfoImpl(clazz.getName(), Modifier.PUBLIC);
+      TypeInfo info = testBasics(clazz, expected);
+      
+      assertFalse(info.isArray());
+      assertFalse(info.isEnum());
+      assertFalse(info.isPrimitive());
+      
+      ClassInfo classInfo = (ClassInfo) info;
+      assertClassInfo(classInfo, clazz);
+   }
+}

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoGenericInterfaceTest.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoGenericInterfaceTest.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoGenericInterfaceTest.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.test;
+
+import java.lang.reflect.Modifier;
+
+import org.jboss.reflect.plugins.ClassInfoImpl;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.test.classinfo.support.ClassInfoGenericFieldsInterface;
+import org.jboss.test.classinfo.support.ClassInfoGenericMethodsInterface;
+
+/**
+ * ClassInfoInterfaceTest.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ClassInfoGenericInterfaceTest extends AbstractClassInfoTest
+{
+   public ClassInfoGenericInterfaceTest(String name)
+   {
+      super(name);
+   }
+
+   public void testGenericMethodsInterface() throws Throwable
+   {
+      testGenericInterface(ClassInfoGenericMethodsInterface.class);
+   }
+   
+   public void testGenericFieldsInterface() throws Throwable
+   {
+      testGenericInterface(ClassInfoGenericFieldsInterface.class);
+   }
+   
+   private void testGenericInterface(Class clazz) throws Throwable
+   {
+      ClassInfoImpl expected = new ClassInfoImpl(clazz.getName(), Modifier.PUBLIC);
+      TypeInfo info = testBasics(clazz, expected);
+      
+      assertFalse(info.isArray());
+      assertFalse(info.isEnum());
+      assertFalse(info.isPrimitive());
+      
+      ClassInfo classInfo = (ClassInfo) info;
+      assertClassInfo(classInfo, clazz);
+   }
+}

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoTestSuite.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoTestSuite.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/ClassInfoTestSuite.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -56,6 +56,8 @@
       suite.addTest(JavassistClassInfoTestCase.suite());
       suite.addTest(IntrospectionAnnotatedClassInfoTestCase.suite());
       suite.addTest(JavassistAnnotatedClassInfoTestCase.suite());
+      suite.addTest(IntrospectionGenericInterfaceUnitTestCase.suite());
+      suite.addTest(IntrospectionGenericClassUnitTestCase.suite());
       
       return suite;
    }

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/IntrospectionGenericClassUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/IntrospectionGenericClassUnitTestCase.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/IntrospectionGenericClassUnitTestCase.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.test;
+
+import junit.framework.Test;
+
+import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
+import org.jboss.reflect.spi.TypeInfoFactory;
+
+/**
+ * Introspection ClassInfo Test Case.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 45663 $
+ */
+public class IntrospectionGenericClassUnitTestCase extends ClassInfoGenericClassTest
+{
+   public static Test suite()
+   {
+      return suite(IntrospectionGenericClassUnitTestCase.class);
+   }
+   
+   public IntrospectionGenericClassUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected TypeInfoFactory getTypeInfoFactory()
+   {
+      return new IntrospectionTypeInfoFactory();
+   }
+
+}
\ No newline at end of file

Added: projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/IntrospectionGenericInterfaceUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/IntrospectionGenericInterfaceUnitTestCase.java	2006-12-04 14:20:46 UTC (rev 58837)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/classinfo/test/IntrospectionGenericInterfaceUnitTestCase.java	2006-12-04 14:40:50 UTC (rev 58838)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.classinfo.test;
+
+import junit.framework.Test;
+
+import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
+import org.jboss.reflect.spi.TypeInfoFactory;
+
+/**
+ * IntrospectionGenericInterfaceUnitTestCase.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class IntrospectionGenericInterfaceUnitTestCase extends ClassInfoGenericInterfaceTest
+{
+   public IntrospectionGenericInterfaceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(IntrospectionGenericInterfaceUnitTestCase.class);
+   }
+
+   protected TypeInfoFactory getTypeInfoFactory()
+   {
+      return new IntrospectionTypeInfoFactory();
+   }
+}




More information about the jboss-cvs-commits mailing list