[jboss-cvs] JBossAS SVN: r102239 - in projects/jboss-reflect/trunk/src: main/java/org/jboss/reflect/plugins/javassist and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 10 12:27:02 EST 2010
Author: kabir.khan at jboss.com
Date: 2010-03-10 12:27:01 -0500 (Wed, 10 Mar 2010)
New Revision: 102239
Added:
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsCollectionComplex.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsMapAndSwapsParameters.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsMapComplex.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsSwappedMapInComplicatedWay.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsSwappedMapInComplicatedWayWIthSpecificType.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericImplementsCollectionComplex.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericImplementsMapComplex.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassCollection.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassComplicated.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassNotGeneric.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceCollection.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceComplicated.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceNotGeneric.java
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistHelper.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistParameterizedClassInfo.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/ClassInfoGenericClassTest.java
Log:
[JBREFLECT-5] Test nested generic types, generic superclass/interfaces that are not generic and cases where the order of the type parameters get swapped around. Move the check for NumberInfo and PrimitiveInfo into the innermost JavassistTypeInfoFactoryImpl.get() method
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2010-03-10 17:18:53 UTC (rev 102238)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoImpl.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -575,7 +575,7 @@
public TypeInfo[] getActualTypeArguments()
{
- return null;
+ return UNKNOWN_TYPES;
}
public TypeInfo getOwnerType()
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistHelper.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistHelper.java 2010-03-10 17:18:53 UTC (rev 102238)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistHelper.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -54,7 +54,7 @@
* @param parameter the index of the type parameter we are looking for
* @return the type
*/
- static String determineType(CtClass clazz, CtClass search, int parameter)
+ static ClassType determineType(CtClass clazz, CtClass search, int parameter)
{
Stack<CtClass> hierarchy = new Stack<CtClass>();
try
@@ -89,11 +89,11 @@
* @param parameter the index of the parameter
* @return the type
*/
- private static String determineType(Stack<CtClass> hierarchy, int parameter)
+ private static ClassType determineType(Stack<CtClass> hierarchy, int parameter)
{
TypeDecider decider = new TypeDecider();
decider.determineType(hierarchy, parameter);
- return decider.name;
+ return decider.classType;
}
private static int determineInfoIndex(TypeInfo[] actualTypeArguments, Stack<CtClass> hierarchy, int parameter)
@@ -132,15 +132,15 @@
/**
* Figures out the path between the passed in classes
*
- * @param hierarchy receives the CtClasses that make up the hierarchy
+ * @param hierarchy receives the CtClasses that make up the hierarchy. This parameter may be null, in which
+ * case is does not receive the classes
* @param current the sub class
* @param search the parent class or interface we are searching for
- * @throws IllegalArgumentException if any of the parameters are null
+ * @return true if the current inherits from search
+ * @throws IllegalArgumentException if current or search is null
*/
- private static boolean determineHierarchy(Stack<CtClass> hierarchy, CtClass current, CtClass search) throws NotFoundException
+ public static boolean determineHierarchy(Stack<CtClass> hierarchy, CtClass current, CtClass search) throws NotFoundException
{
- if (hierarchy == null)
- throw new IllegalArgumentException("Null hierarchy");
if (current == null)
throw new IllegalArgumentException("Null current");
if (search == null)
@@ -148,9 +148,10 @@
if (current == null)
return false;
+
+ if (hierarchy != null)
+ hierarchy.push(current);
- hierarchy.push(current);
-
if (current.equals(search))
return true;
@@ -170,7 +171,8 @@
if (result)
return true;
- hierarchy.pop();
+ if (hierarchy != null)
+ hierarchy.pop();
return false;
}
@@ -217,7 +219,8 @@
{
int lastIndex;
CtClass last = null;
- String name;
+// String name;
+ ClassType classType;
private void determineType(Stack<CtClass> hierarchy, int parameter)
{
@@ -252,7 +255,8 @@
continue;
if (type instanceof ClassType)
{
- name = ((ClassType) type).getName();
+ //name = ((ClassType) type).getName();
+ classType = (ClassType)type;
return;
}
@@ -279,9 +283,9 @@
if (targetType != null)
{
//TODO also check interfaces
- name = ((ClassType)targetType.getClassBound()).getName();
+ classType = (ClassType)targetType.getClassBound();
return;
}
}
- }
+ }
}
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistParameterizedClassInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistParameterizedClassInfo.java 2010-03-10 17:18:53 UTC (rev 102238)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistParameterizedClassInfo.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -26,6 +26,8 @@
import javassist.CtClass;
import javassist.bytecode.SignatureAttribute.ClassSignature;
+import javassist.bytecode.SignatureAttribute.ClassType;
+import javassist.bytecode.SignatureAttribute.ObjectType;
import javassist.bytecode.SignatureAttribute.TypeArgument;
import org.jboss.reflect.plugins.ClassInfoImpl;
@@ -33,6 +35,7 @@
import org.jboss.reflect.spi.DelegateClassInfo;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.util.JBossStringBuilder;
/**
*
@@ -74,26 +77,42 @@
@Override
public TypeInfo[] getActualTypeArguments()
{
- if (typeArgumentInfos == ClassInfoImpl.UNKNOWN_TYPES && typeArguments.length > 0)
+ if (typeArgumentInfos == ClassInfoImpl.UNKNOWN_TYPES && typeArguments != null && typeArguments.length > 0)
{
- try
+ TypeInfo[] infos = new TypeInfo[typeArguments.length];
+ for (int i = 0 ; i < typeArguments.length ; i++)
{
- TypeInfo[] infos = new TypeInfo[typeArguments.length];
- for (int i = 0 ; i < typeArguments.length ; i++)
- {
- infos[i] = (TypeInfo)factory.get(typeArguments[i].getType().toString(), delegate.getClassLoader());
- }
- typeArgumentInfos = infos;
+ infos[i] = createTypeInfo(typeArguments[i], delegate.getClassLoader());
}
- catch (ClassNotFoundException e)
- {
- // AutoGenerated
- throw new RuntimeException(e);
- }
+ typeArgumentInfos = infos;
}
return typeArgumentInfos;
}
+
+ private TypeInfo createTypeInfo(TypeArgument arg, ClassLoader loader)
+ {
+ try
+ {
+ ObjectType type = arg.getType();
+ if (type instanceof ClassType)
+ {
+ ClassInfo info = (ClassInfo)factory.get(((ClassType)type).getName(), delegate.getClassLoader());
+ TypeArgument[] args = ((ClassType)type).getTypeArguments();
+ if (args != null && args.length > 0)
+ {
+ info = new JavassistParameterizedClassInfo(factory, info, args);
+ }
+ return info;
+ }
+ throw new IllegalStateException("Unhandled type " + type);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // AutoGenerated
+ throw new RuntimeException(e);
+ }
+ }
@Override
public TypeInfo getComponentType()
@@ -134,7 +153,45 @@
throw new RuntimeException(e1);
}
}
+
+ @Override
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ appendTypeGenericInfo(this, buffer);
+ }
+ private void appendTypeGenericInfo(TypeInfo info, JBossStringBuilder buffer)
+ {
+ boolean first = true;
+
+ buffer.append(info.getName());
+ if (info instanceof ClassInfo)
+ {
+ ClassInfo cinfo = (ClassInfo)info;
+ if (((ClassInfo) info).getActualTypeArguments().length > 0)
+ {
+ buffer.append("<");
+ for (TypeInfo arg : cinfo.getActualTypeArguments())
+ {
+ if (!first)
+ buffer.append(", ");
+ else
+ first = false;
+
+ appendTypeGenericInfo(arg, buffer);
+
+ }
+ buffer.append(">");
+ }
+ }
+ }
+
+ @Override
+ protected void toString(JBossStringBuilder buffer)
+ {
+ toShortString(buffer);
+ }
+
private static interface TypeChecker
{
boolean check(JavassistParameterizedClassInfo info);
@@ -159,4 +216,5 @@
return info.isCollection();
}
}
+
}
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2010-03-10 17:18:53 UTC (rev 102238)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfo.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -24,12 +24,8 @@
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
import java.util.Collection;
import java.util.Map;
-import java.util.Stack;
import java.util.concurrent.ConcurrentHashMap;
import javassist.CannotCompileException;
@@ -47,7 +43,6 @@
import org.jboss.reflect.plugins.PackageInfoImpl;
import org.jboss.reflect.plugins.TypeInfoAttachments;
import org.jboss.reflect.plugins.ValueConvertor;
-import org.jboss.reflect.plugins.introspection.ParameterizedClassInfo;
import org.jboss.reflect.spi.AnnotationValue;
import org.jboss.reflect.spi.Body;
import org.jboss.reflect.spi.ClassInfo;
@@ -61,8 +56,6 @@
import org.jboss.reflect.spi.TypeInfoFactory;
import org.jboss.util.JBossStringBuilder;
-import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
-
/**
* JavassistTypeInfo.
*
@@ -125,6 +118,18 @@
/** The value type if this is a Map */
private volatile TypeInfo valueType = ClassInfoImpl.UNKNOWN_TYPE;
+ /** Whether we have initialized isMap */
+ private volatile boolean initializedIsMap;
+
+ /** Whether we are a map */
+ private volatile boolean isMap;
+
+ /** Whether we have initialized isMap */
+ private volatile boolean initializedIsCollection;
+
+ /** Whether we are a map */
+ private volatile boolean isCollection;
+
/**
* Create a new JavassistTypeInfo.
*
@@ -165,7 +170,7 @@
public String getSimpleName()
{
- return getType().getSimpleName();
+ return ctClass.getSimpleName();
}
public int getModifiers()
@@ -231,25 +236,38 @@
{
ClassSignature classSig = JavassistHelper.getClassSignature(ctClass);
- ClassType type = classSig.getSuperClass();
- String name = type.getName();
- //TypeArgument[] arguments = type.getTypeArguments();
-
- ClassInfo delegate;
- try
+ if (classSig != null)
{
- delegate = (ClassInfo)factory.get(name, getClassLoader());
+ ClassType type = classSig.getSuperClass();
+ genericSuperClass = getParameterizedClassInfo(type);
}
- catch (ClassNotFoundException e)
+ else
{
- throw new IllegalStateException(e);
+ genericSuperClass = getSuperclass();
}
- genericSuperClass = new JavassistParameterizedClassInfo(factory, delegate, type.getTypeArguments());
}
return genericSuperClass;
}
+ private ClassInfo getParameterizedClassInfo(ClassType type)
+ {
+ String name = type.getName();
+
+ ClassInfo delegate;
+ try
+ {
+ delegate = (ClassInfo)factory.get(name, getClassLoader());
+ if (type.getTypeArguments() == null || type.getTypeArguments().length == 0)
+ return delegate;
+ return new JavassistParameterizedClassInfo(factory, delegate, type.getTypeArguments());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+
public InterfaceInfo[] getInterfaces()
{
try
@@ -275,24 +293,24 @@
InterfaceInfo[] infos = new InterfaceInfo[getInterfaces().length];
ClassSignature classSig = JavassistHelper.getClassSignature(ctClass);
- ClassType[] types = classSig.getInterfaces();
- for (int i = 0 ; i < types.length ; i++)
+
+ if (classSig != null)
{
- String name = types[i].getName();
-
- ClassInfo delegate;
- try
+ ClassType[] types = classSig.getInterfaces();
+ for (int i = 0 ; i < types.length ; i++)
{
- delegate = (ClassInfo)factory.get(name, getClassLoader());
- }
- catch (ClassNotFoundException e)
- {
- throw new IllegalStateException(e);
- }
- infos[i] = new JavassistParameterizedClassInfo(factory, delegate, types[i].getTypeArguments());
- }
+ ClassInfo info = getParameterizedClassInfo(types[i]);
+ if (info instanceof InterfaceInfo == false)
+ throw new IllegalStateException(info + " is not an InterfaceInfo");
+ infos[i] = (InterfaceInfo)info;
+ }
- genericInterfaces = infos;
+ genericInterfaces = infos;
+ }
+ else
+ {
+ genericInterfaces = getInterfaces();
+ }
}
return genericInterfaces;
}
@@ -454,16 +472,38 @@
return getCtClass().isArray();
}
- //TODO: need to change the use of getType() here
public boolean isCollection()
{
- return Collection.class.isAssignableFrom(getType());
+ if (!initializedIsCollection)
+ {
+ try
+ {
+ isCollection = JavassistHelper.determineHierarchy(null, ctClass, ctClass.getClassPool().get(Collection.class.getName()));
+ initializedIsCollection = true;
+ }
+ catch (NotFoundException e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+ return isCollection;
}
- //TODO: need to change the use of getType() here
public boolean isMap()
{
- return Map.class.isAssignableFrom(getType());
+ if (!initializedIsMap)
+ {
+ try
+ {
+ isMap = JavassistHelper.determineHierarchy(null, ctClass, ctClass.getClassPool().get(Map.class.getName()));
+ initializedIsMap = true;
+ }
+ catch (NotFoundException e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+ return isMap;
}
public boolean isAnnotation()
@@ -754,7 +794,7 @@
public TypeInfo[] getActualTypeArguments()
{
- return null;
+ return ClassInfoImpl.UNKNOWN_TYPES;
}
public TypeInfo getOwnerType()
@@ -808,8 +848,8 @@
try
{
CtClass collection = ctClass.getClassPool().get(target);
- String componentName = JavassistHelper.determineType(ctClass, collection, parameter);
- return getTypeInfoFactory().getTypeInfo(componentName, getClassLoader());
+ ClassType type = JavassistHelper.determineType(ctClass, collection, parameter);
+ return getParameterizedClassInfo(type);
}
catch (Exception e1)
{
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2010-03-10 17:18:53 UTC (rev 102238)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -313,9 +313,38 @@
{
if (ctClass == null)
throw new IllegalArgumentException("Null class");
- if(ctClass instanceof CtPrimitiveType)
- return instantiate(ctClass, clazz);
+ TypeInfo primitive = PrimitiveInfo.valueOf(ctClass.getName());
+ if (primitive != null)
+ return primitive;
+
+ NumberInfo number = NumberInfo.valueOf(ctClass.getName());
+ if (number != null)
+ {
+ synchronized (number)
+ {
+ if (number.getPhase() != NumberInfo.Phase.INITIALIZING)
+ {
+ if (number.getPhase() != NumberInfo.Phase.COMPLETE)
+ {
+ number.initializing();
+ Class<?> useClass = clazz;
+ try
+ {
+ if (useClass == null)
+ useClass = ctClass.getClassPool().getClassLoader().loadClass(ctClass.getName());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ number.setDelegate(get(clazz));
+ }
+ return number;
+ }
+ }
+ }
+
Map<String, WeakReference<TypeInfo>> classLoaderCache = getClassLoaderCache(ctClass.getClassPool().getClassLoader());
WeakReference<TypeInfo> weak = classLoaderCache.get(ctClass.getName());
@@ -446,30 +475,10 @@
if (clazz == null)
throw new IllegalArgumentException("Null class");
- TypeInfo primitive = PrimitiveInfo.valueOf(clazz.getName());
- if (primitive != null)
- return primitive;
-
- NumberInfo number = NumberInfo.valueOf(clazz.getName());
- if (number != null)
- {
- synchronized (number)
- {
- if (number.getPhase() != NumberInfo.Phase.INITIALIZING)
- {
- if (number.getPhase() != NumberInfo.Phase.COMPLETE)
- {
- number.initializing();
- number.setDelegate(get(clazz));
- }
- return number;
- }
- }
- }
-
return get(clazz);
}
+
public TypeInfo getTypeInfo(String name, ClassLoader cl) throws ClassNotFoundException
{
if (name == null)
@@ -513,27 +522,6 @@
throw new org.jboss.util.NotImplementedException("getTypeInfo");
}
- private TypeInfo getParameterizedType(ParameterizedType type)
- {
- Class<?> rawType = (Class<?>)type.getRawType();
- ClassInfo raw = (ClassInfo)getTypeInfo(rawType);
- Type[] types = type.getActualTypeArguments();
- TypeInfo[] typeInfos = new TypeInfo[types.length];
- for (int i = 0 ; i < typeInfos.length ; i++)
- {
- try
- {
-// if (types[i].)
- typeInfos[i] = getTypeInfo(types[i]);
- }
- catch (Exception e)
- {
- throw new IllegalStateException(e);
- }
- }
- return new JavassistParameterizedClassInfo(this, raw, typeInfos);
- }
-
public AnnotationValue[] getAnnotations(Object obj)
{
try
@@ -630,4 +618,26 @@
CtClass clazz = poolFactory.getPoolForLoader(superClass.getClassLoader()).makeInterface(name, JavassistUtil.toCtClass(superClass));
return new JavassistTypeInfo(this, clazz, null);
}
+
+ protected TypeInfo getParameterizedType(ParameterizedType type)
+ {
+ Class<?> rawType = (Class<?>)type.getRawType();
+ ClassInfo raw = (ClassInfo)getTypeInfo(rawType);
+ Type[] types = type.getActualTypeArguments();
+ TypeInfo[] typeInfos = new TypeInfo[types.length];
+
+ for (int i = 0 ; i < typeInfos.length ; i++)
+ {
+ try
+ {
+ typeInfos[i] = getTypeInfo(types[i]);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+ return new JavassistParameterizedClassInfo(this, raw, typeInfos);
+ }
+
}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsCollectionComplex.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsCollectionComplex.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsCollectionComplex.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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;
+
+import java.util.AbstractCollection;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericExtendsCollectionComplex extends AbstractCollection<Map<String, Class<String>>>
+{
+
+ @Override
+ public Iterator<Map<String, Class<String>>> iterator()
+ {
+ return null;
+ }
+
+ @Override
+ public int size()
+ {
+ return 0;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsMapAndSwapsParameters.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsMapAndSwapsParameters.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsMapAndSwapsParameters.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -0,0 +1,40 @@
+/*
+* 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;
+
+import java.util.Set;
+
+/**
+ * ClassInfoGenericExtendsCollectionAndChangesParameter.
+ *
+ * @param <A> the changed parameter name
+ * @param <B> the changed parameter name
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericExtendsMapAndSwapsParameters<A, B> extends ClassInfoGenericExtendsMapAndChangesParameters<B, A>
+{
+ public Set<java.util.Map.Entry<B, A>> entrySet()
+ {
+ return null;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsMapComplex.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsMapComplex.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsMapComplex.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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;
+
+import java.util.AbstractMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericExtendsMapComplex extends AbstractMap<List<Class<String>>, Map<Class<String>, List<Long>>>
+{
+ @Override
+ public Set<java.util.Map.Entry<List<Class<String>>, Map<Class<String>, List<Long>>>> entrySet()
+ {
+ return null;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsSwappedMapInComplicatedWay.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsSwappedMapInComplicatedWay.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsSwappedMapInComplicatedWay.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -0,0 +1,36 @@
+/*
+* 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;
+
+/**
+ * ClassInfoGenericExtendsCollectionInComplicatedWay.
+ *
+ * @param <A>
+ * @param <B>
+ * @param <C> the key type
+ * @param <D> the value type
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericExtendsSwappedMapInComplicatedWay<A, B, C, D> extends ClassInfoGenericExtendsMapAndSwapsParameters<C, D>
+{
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsSwappedMapInComplicatedWayWIthSpecificType.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsSwappedMapInComplicatedWayWIthSpecificType.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericExtendsSwappedMapInComplicatedWayWIthSpecificType.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -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;
+
+/**
+ * ClassInfoGenericExtendsCollectionInComplicatedWayWIthSpecificType.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericExtendsSwappedMapInComplicatedWayWIthSpecificType extends ClassInfoGenericExtendsSwappedMapInComplicatedWay<String, Integer, Double, Short>
+{
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericImplementsCollectionComplex.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericImplementsCollectionComplex.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericImplementsCollectionComplex.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericImplementsCollectionComplex implements Collection<Map<String, Class<String>>>
+{
+
+ public boolean add(Map<String, Class<String>> e)
+ {
+ return false;
+ }
+
+ public boolean addAll(Collection<? extends Map<String, Class<String>>> c)
+ {
+ return false;
+ }
+
+ public void clear()
+ {
+ }
+
+ public boolean contains(Object o)
+ {
+ return false;
+ }
+
+ public boolean containsAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ public Iterator<Map<String, Class<String>>> iterator()
+ {
+ return null;
+ }
+
+ public boolean remove(Object o)
+ {
+ return false;
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ return false;
+ }
+
+ public int size()
+ {
+ return 0;
+ }
+
+ public Object[] toArray()
+ {
+ return null;
+ }
+
+ public <T> T[] toArray(T[] a)
+ {
+ return null;
+ }
+
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericImplementsMapComplex.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericImplementsMapComplex.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericImplementsMapComplex.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -0,0 +1,93 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericImplementsMapComplex implements Map<List<Class<String>>, Map<Class<String>, List<Long>>>
+{
+ public void clear()
+ {
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return false;
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return false;
+ }
+
+ public Set<java.util.Map.Entry<List<Class<String>>, Map<Class<String>, List<Long>>>> entrySet()
+ {
+ return null;
+ }
+
+ public Map<Class<String>, List<Long>> get(Object key)
+ {
+ return null;
+ }
+
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ public Set<List<Class<String>>> keySet()
+ {
+ return null;
+ }
+
+ public Map<Class<String>, List<Long>> put(List<Class<String>> key, Map<Class<String>, List<Long>> value)
+ {
+ return null;
+ }
+
+ public void putAll(Map<? extends List<Class<String>>, ? extends Map<Class<String>, List<Long>>> m)
+ {
+ }
+
+ public Map<Class<String>, List<Long>> remove(Object key)
+ {
+ return null;
+ }
+
+ public int size()
+ {
+ return 0;
+ }
+
+ public Collection<Map<Class<String>, List<Long>>> values()
+ {
+ return null;
+ }
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassCollection.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassCollection.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassCollection.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -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;
+
+import java.util.Collection;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericSuperClassCollection extends ClassInfoGenericClass<Collection<String>>
+{
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassComplicated.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassComplicated.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassComplicated.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -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;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericSuperClassComplicated extends ClassInfoGenericClass<Collection<Map<String, Class<String>>>>
+{
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassNotGeneric.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassNotGeneric.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperClassNotGeneric.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -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;
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at SuppressWarnings("unchecked")
+public class ClassInfoGenericSuperClassNotGeneric extends ClassInfoGenericClass
+{
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceCollection.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceCollection.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceCollection.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -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;
+
+import java.util.Collection;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericSuperInterfaceCollection implements ClassInfoGenericInterface<Collection<String>>
+{
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceComplicated.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceComplicated.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceComplicated.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -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;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassInfoGenericSuperInterfaceComplicated implements ClassInfoGenericInterface<Collection<Map<String, Class<String>>>>
+{
+}
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceNotGeneric.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceNotGeneric.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/support/ClassInfoGenericSuperInterfaceNotGeneric.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -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;
+
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at SuppressWarnings("unchecked")
+public class ClassInfoGenericSuperInterfaceNotGeneric implements ClassInfoGenericInterface
+{
+}
Modified: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/ClassInfoGenericClassTest.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/ClassInfoGenericClassTest.java 2010-03-10 17:18:53 UTC (rev 102238)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/classinfo/test/ClassInfoGenericClassTest.java 2010-03-10 17:27:01 UTC (rev 102239)
@@ -22,10 +22,12 @@
package org.jboss.test.classinfo.test;
import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
+import java.util.List;
import java.util.Map;
import org.jboss.reflect.plugins.ClassInfoImpl;
@@ -39,27 +41,41 @@
import org.jboss.test.classinfo.support.ClassInfoGenericConstructorsClass;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsCollection;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsCollectionAndChangesParameter;
+import org.jboss.test.classinfo.support.ClassInfoGenericExtendsCollectionComplex;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsCollectionInComplicatedWay;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsCollectionInComplicatedWayWIthSpecificType;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsCollectionNotGeneric;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsMap;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsMapAndChangesParameters;
+import org.jboss.test.classinfo.support.ClassInfoGenericExtendsMapAndSwapsParameters;
+import org.jboss.test.classinfo.support.ClassInfoGenericExtendsMapComplex;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsMapInComplicatedWay;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsMapInComplicatedWayWIthSpecificType;
import org.jboss.test.classinfo.support.ClassInfoGenericExtendsMapNotGeneric;
+import org.jboss.test.classinfo.support.ClassInfoGenericExtendsSwappedMapInComplicatedWay;
+import org.jboss.test.classinfo.support.ClassInfoGenericExtendsSwappedMapInComplicatedWayWIthSpecificType;
import org.jboss.test.classinfo.support.ClassInfoGenericFieldsClass;
import org.jboss.test.classinfo.support.ClassInfoGenericImplementsCollection;
+import org.jboss.test.classinfo.support.ClassInfoGenericImplementsCollectionComplex;
import org.jboss.test.classinfo.support.ClassInfoGenericImplementsCollectionNotGeneric;
import org.jboss.test.classinfo.support.ClassInfoGenericImplementsMap;
+import org.jboss.test.classinfo.support.ClassInfoGenericImplementsMapComplex;
import org.jboss.test.classinfo.support.ClassInfoGenericImplementsMapNotGeneric;
import org.jboss.test.classinfo.support.ClassInfoGenericInterface;
import org.jboss.test.classinfo.support.ClassInfoGenericMethodsClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperClassCollection;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperClassComplicated;
import org.jboss.test.classinfo.support.ClassInfoGenericSuperClassEmptyClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperClassNotGeneric;
import org.jboss.test.classinfo.support.ClassInfoGenericSuperClassString;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperInterfaceCollection;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperInterfaceComplicated;
import org.jboss.test.classinfo.support.ClassInfoGenericSuperInterfaceEmptyClass;
+import org.jboss.test.classinfo.support.ClassInfoGenericSuperInterfaceNotGeneric;
import org.jboss.test.classinfo.support.ClassInfoGenericSuperInterfaceString;
+
/**
* ClassInfoGenericClassTest.
*
@@ -73,6 +89,11 @@
super(name);
}
+ public void testGenericSuperClass()
+ {
+
+ }
+
public void testGenericSuperClassString()
{
testGenericSuperClass(ClassInfoGenericSuperClassString.class, ClassInfoGenericClass.class, new Class[] { String.class });
@@ -83,6 +104,27 @@
testGenericSuperClass(ClassInfoGenericSuperClassEmptyClass.class, ClassInfoGenericClass.class, new Class[] { ClassInfoEmptyClass.class });
}
+ public void testGenericSuperClassNotGeneric()
+ {
+ testGenericSuperClass(ClassInfoGenericSuperClassNotGeneric.class, ClassInfoGenericClass.class, new Class[0]);
+ }
+
+ public void testGenericSuperClassCollection()
+ {
+ ParameterizedType type = assertInstanceOf(ClassInfoGenericSuperClassCollection.class.getGenericSuperclass(), ParameterizedType.class);
+ assertNotNull(type.getActualTypeArguments());
+ assertEquals(1, type.getActualTypeArguments().length);
+ testGenericSuperClass(ClassInfoGenericSuperClassCollection.class, ClassInfoGenericClass.class, new Type[] { type.getActualTypeArguments()[0] });
+ }
+
+ public void testGenericSuperClassComplicated()
+ {
+ ParameterizedType type = assertInstanceOf(ClassInfoGenericSuperClassComplicated.class.getGenericSuperclass(), ParameterizedType.class);
+ assertNotNull(type.getActualTypeArguments());
+ assertEquals(1, type.getActualTypeArguments().length);
+ testGenericSuperClass(ClassInfoGenericSuperClassComplicated.class, ClassInfoGenericClass.class, new Type[] { type.getActualTypeArguments()[0] });
+ }
+
public void testGenericSuperInterfaceString()
{
testGenericSuperInterface(ClassInfoGenericSuperInterfaceString.class, ClassInfoGenericInterface.class, new Class[] { String.class });
@@ -93,8 +135,33 @@
testGenericSuperInterface(ClassInfoGenericSuperInterfaceEmptyClass.class, ClassInfoGenericInterface.class, new Class[] { ClassInfoEmptyClass.class });
}
- public void testGenericSuperClass(Class<?> clazz, Class<?> genericClass, Class<?>[] genericTypes)
+ public void testGenericSuperInterfaceNotGeneric()
{
+ testGenericSuperInterface(ClassInfoGenericSuperInterfaceNotGeneric.class, ClassInfoGenericInterface.class, new Class[0]);
+ }
+
+ public void testGenericSuperInterfaceCollection()
+ {
+ Type[] infos = ClassInfoGenericSuperInterfaceCollection.class.getGenericInterfaces();
+ assertEquals(1, infos.length);
+ ParameterizedType type = assertInstanceOf(infos[0], ParameterizedType.class);
+ assertNotNull(type.getActualTypeArguments());
+ assertEquals(1, type.getActualTypeArguments().length);
+ testGenericSuperInterface(ClassInfoGenericSuperInterfaceCollection.class, ClassInfoGenericInterface.class, new Type[] { type.getActualTypeArguments()[0] });
+ }
+
+ public void testGenericSuperInterfaceComplicated()
+ {
+ Type[] infos = ClassInfoGenericSuperInterfaceComplicated.class.getGenericInterfaces();
+ assertEquals(1, infos.length);
+ ParameterizedType type = assertInstanceOf(infos[0], ParameterizedType.class);
+ assertNotNull(type.getActualTypeArguments());
+ assertEquals(1, type.getActualTypeArguments().length);
+ testGenericSuperInterface(ClassInfoGenericSuperInterfaceComplicated.class, ClassInfoGenericInterface.class, new Type[] { type.getActualTypeArguments()[0] });
+ }
+
+ protected void testGenericSuperClass(Class<?> clazz, Class<?> genericClass, Type[] genericTypes)
+ {
TypeInfoFactory factory = getTypeInfoFactory();
ClassInfo typeInfo = (ClassInfo) factory.getTypeInfo(clazz);
ClassInfo superClassInfo = typeInfo.getGenericSuperclass();
@@ -106,13 +173,15 @@
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));
+ getLog().debug("Checking superClass types: " + Arrays.asList(types) + " against " + Arrays.asList(actualTypes));
assertEquals(types.length, actualTypes.length);
for (int i = 0; i < types.length; ++i)
assertEquals(types[i], actualTypes[i]);
+
+ testGenericSuperClassAgainstRawReflect(clazz, genericClass, genericTypes);
}
-
- public void testGenericSuperInterface(Class<?> clazz, Class<?> genericClass, Class<?>[] genericTypes)
+
+ public void testGenericSuperInterface(Class<?> clazz, Class<?> genericClass, Type[] genericTypes)
{
TypeInfoFactory factory = getTypeInfoFactory();
ClassInfo typeInfo = (ClassInfo) factory.getTypeInfo(clazz);
@@ -132,6 +201,8 @@
assertEquals(types.length, actualTypes.length);
for (int i = 0; i < types.length; ++i)
assertEquals(types[i], actualTypes[i]);
+
+ testGenericSuperInterfaceAgainstRawReflect(clazz, genericClass, genericTypes);
}
public void testGenericMethodsClass() throws Throwable
@@ -184,6 +255,33 @@
assertComponentType(ClassInfoGenericExtendsCollection.class, Short.class);
}
+ public static Collection<Map<String, Class<String>>> signatureCollectionComplex()
+ {
+ return null;
+ }
+
+ public void testComponentTypeCollectionComplex() throws Throwable
+ {
+ ParameterizedType type = assertInstanceOf(getGenericReturnType("signatureCollectionComplex"), ParameterizedType.class);
+ assertEquals(1, type.getActualTypeArguments().length);
+ assertComponentType("signatureCollectionComplex", type.getActualTypeArguments()[0]);
+ }
+
+ public void testComponentTypeImplementsCollectionComplex() throws Throwable
+ {
+ assertEquals(1, ClassInfoGenericImplementsCollectionComplex.class.getGenericInterfaces().length);
+ ParameterizedType type = assertInstanceOf(ClassInfoGenericImplementsCollectionComplex.class.getGenericInterfaces()[0], ParameterizedType.class);
+ assertEquals(1, type.getActualTypeArguments().length);
+ assertComponentType(ClassInfoGenericImplementsCollectionComplex.class, type.getActualTypeArguments()[0]);
+ }
+
+ public void testComponentTypeExtendsCollectionComplex() throws Throwable
+ {
+ ParameterizedType type = assertInstanceOf(ClassInfoGenericExtendsCollectionComplex.class.getGenericSuperclass(), ParameterizedType.class);
+ assertEquals(1, type.getActualTypeArguments().length);
+ assertComponentType(ClassInfoGenericExtendsCollectionComplex.class, type.getActualTypeArguments()[0]);
+ }
+
public void testComponentTypeExtendsCollectionAndChangesParameter() throws Throwable
{
assertComponentType(ClassInfoGenericExtendsCollectionAndChangesParameter.class, Object.class);
@@ -254,6 +352,33 @@
assertKeyValueType(ClassInfoGenericExtendsMap.class, Short.class, Double.class);
}
+ public static Map<List<Class<String>>, Map<String, Class<String>>> signatureMapComplex()
+ {
+ return null;
+ }
+
+ public void testKeyValueTypeCollectionComplex() throws Throwable
+ {
+ ParameterizedType type = assertInstanceOf(getGenericReturnType("signatureMapComplex"), ParameterizedType.class);
+ assertEquals(2, type.getActualTypeArguments().length);
+ assertKeyValueType("signatureMapComplex", type.getActualTypeArguments()[0], type.getActualTypeArguments()[1]);
+ }
+
+ public void testKeyValueTypeImplementsMapComplex() throws Throwable
+ {
+ assertEquals(1, ClassInfoGenericImplementsMapComplex.class.getGenericInterfaces().length);
+ ParameterizedType type = assertInstanceOf(ClassInfoGenericImplementsMapComplex.class.getGenericInterfaces()[0], ParameterizedType.class);
+ assertEquals(2, type.getActualTypeArguments().length);
+ assertKeyValueType(ClassInfoGenericImplementsMapComplex.class, type.getActualTypeArguments()[0], type.getActualTypeArguments()[1]);
+ }
+
+ public void testKeyValueTypeExtendsMapComplex() throws Throwable
+ {
+ ParameterizedType type = assertInstanceOf(ClassInfoGenericExtendsMapComplex.class.getGenericSuperclass(), ParameterizedType.class);
+ assertEquals(2, type.getActualTypeArguments().length);
+ assertKeyValueType(ClassInfoGenericExtendsMapComplex.class, type.getActualTypeArguments()[0], type.getActualTypeArguments()[1]);
+ }
+
public void testKeyValueTypeExtendsMapAndChangesParameters() throws Throwable
{
assertKeyValueType(ClassInfoGenericExtendsMapAndChangesParameters.class, Object.class, Object.class);
@@ -288,16 +413,55 @@
{
assertKeyValueType(ClassInfoGenericExtendsMapInComplicatedWayWIthSpecificType.class, Double.class, Short.class);
}
+
+ public void testKeyValueTypeExtendsMapAndSwapsParameters() throws Throwable
+ {
+ assertKeyValueType(ClassInfoGenericExtendsMapAndSwapsParameters.class, Object.class, Object.class);
+ }
- private void assertComponentType(String methodName, Class<?> expected) throws Exception
+ public static ClassInfoGenericExtendsMapAndSwapsParameters<Float, Double> signatureMapSwapsParameter()
{
+ return null;
+ }
+
+ public void testKeyValueTypeExtendsMapAndSwapsParameterExplicit() throws Throwable
+ {
+ assertKeyValueType("signatureMapSwapsParameter", Double.class, Float.class);
+ }
+
+ public void testKeyValueTypeExtendsSwappedMapInAComplicatedWay() throws Throwable
+ {
+ assertKeyValueType(ClassInfoGenericExtendsSwappedMapInComplicatedWay.class, Object.class, Object.class);
+ }
+
+ public static ClassInfoGenericExtendsSwappedMapInComplicatedWay<String, Float, Date, StringBuffer> signatureSwappedMapComplicatedWay()
+ {
+ return null;
+ }
+
+ public void ClassInfoGenericExtendsSwappedMapInComplicatedWay() throws Throwable
+ {
+ assertKeyValueType("signatureSwappedMapComplicatedWay", StringBuffer.class, Date.class);
+ }
+
+ public void testComponentTypeExtendsSweappedMapInAComplicatedWayWithSpecificType() throws Throwable
+ {
+ assertKeyValueType(ClassInfoGenericExtendsSwappedMapInComplicatedWayWIthSpecificType.class, Short.class, Double.class);
+ }
+
+ private Type getGenericReturnType(String methodName) throws Exception
+ {
Method method = ClassInfoGenericClassTest.class.getMethod(methodName, (Class[]) null);
- Type type = method.getGenericReturnType();
- assertComponentType(type, expected);
+ return method.getGenericReturnType();
}
- private void assertComponentType(Type type, Class<?> expected) throws Exception
+ private void assertComponentType(String methodName, Type expected) throws Exception
{
+ assertComponentType(getGenericReturnType(methodName), expected);
+ }
+
+ private void assertComponentType(Type type, Type expected) throws Exception
+ {
TypeInfoFactory factory = getTypeInfoFactory();
TypeInfo typeInfo = factory.getTypeInfo(type);
ClassInfo classInfo = assertInstanceOf(typeInfo, ClassInfo.class);
@@ -305,16 +469,18 @@
TypeInfo expectedInfo = factory.getTypeInfo(expected);
assertEquals(expectedInfo, classInfo.getComponentType());
+
+ assertTypeAgainstRawReflect(expected, classInfo.getComponentType());
}
- private void assertKeyValueType(String methodName, Class<?> keyExpected, Class<?> valueExpected) throws Exception
+ private void assertKeyValueType(String methodName, Type keyExpected, Type valueExpected) throws Exception
{
Method method = ClassInfoGenericClassTest.class.getMethod(methodName, (Class[]) null);
Type type = method.getGenericReturnType();
assertKeyValueType(type, keyExpected, valueExpected);
}
- private void assertKeyValueType(Type type, Class<?> keyExpected, Class<?> valueExpected) throws Exception
+ private void assertKeyValueType(Type type, Type keyExpected, Type valueExpected) throws Exception
{
TypeInfoFactory factory = getTypeInfoFactory();
TypeInfo typeInfo = factory.getTypeInfo(type);
@@ -326,6 +492,8 @@
expectedInfo = factory.getTypeInfo(valueExpected);
assertEquals(expectedInfo, classInfo.getValueType());
+
+ //TODO check raw parameters
}
private void testGenericClass(Class<?> clazz) throws Throwable
@@ -340,4 +508,99 @@
ClassInfo classInfo = (ClassInfo) info;
assertClassInfo(classInfo, clazz);
}
-}
+
+ protected void testGenericSuperClassAgainstRawReflect(Class<?> clazz, Class<?> genericClass, Type[] genericTypes)
+ {
+ if (genericTypes == null || genericTypes.length == 0)
+ {
+ Class<?> superClass = assertInstanceOf(clazz.getGenericSuperclass(), Class.class);
+ assertEquals(genericClass, superClass);
+ }
+ else
+ {
+ //Just check all the standard reflect stuff
+ ParameterizedType superClass = assertInstanceOf(clazz.getGenericSuperclass(), ParameterizedType.class);
+ assertEquals(genericClass, superClass.getRawType());
+ Type[] reflectTypes = superClass.getActualTypeArguments();
+ assertEquals(genericTypes.length, reflectTypes.length);
+ for (int i = 0 ; i < genericTypes.length ; i++)
+ assertEquals(genericTypes[i], reflectTypes[i]);
+
+ //Compare the classinfo stuff vs raw reflect
+ TypeInfoFactory factory = getTypeInfoFactory();
+ ClassInfo typeInfo = (ClassInfo) factory.getTypeInfo(clazz);
+ assertEquals(clazz.getName(), typeInfo.getName());
+
+ ClassInfo superClassInfo = typeInfo.getGenericSuperclass();
+ assertEquals(genericClass.getName(), superClassInfo.getName());
+
+ assertTypeArgumentsAgainstRawReflect(reflectTypes, superClassInfo.getActualTypeArguments());
+ }
+ }
+
+ protected void testGenericSuperInterfaceAgainstRawReflect(Class<?> clazz, Class<?> genericClass, Type[] genericTypes)
+ {
+ Type[] interfaces = clazz.getGenericInterfaces();
+ assertEquals(1, interfaces.length);
+
+ if (genericTypes == null || genericTypes.length == 0)
+ {
+ Class<?> iface = assertInstanceOf(interfaces[0], Class.class);
+ assertEquals(genericClass, iface);
+ }
+ else
+ {
+ //Just check all the standard reflect stuff
+ ParameterizedType iface = assertInstanceOf(interfaces[0], ParameterizedType.class);
+ assertEquals(genericClass, iface.getRawType());
+ Type[] reflectTypes = iface.getActualTypeArguments();
+ assertEquals(genericTypes.length, reflectTypes.length);
+ for (int i = 0 ; i < genericTypes.length ; i++)
+ assertEquals(genericTypes[i], reflectTypes[i]);
+
+ //Compare the classinfo stuff vs raw reflect
+ TypeInfoFactory factory = getTypeInfoFactory();
+ ClassInfo typeInfo = (ClassInfo) factory.getTypeInfo(clazz);
+ assertEquals(clazz.getName(), typeInfo.getName());
+
+ InterfaceInfo[] superInterfaces = typeInfo.getGenericInterfaces();
+ assertNotNull(superInterfaces);
+ assertEquals(1, superInterfaces.length);
+ InterfaceInfo superInterface = superInterfaces[0];
+ assertEquals(genericClass.getName(), superInterface.getName());
+
+ assertTypeArgumentsAgainstRawReflect(reflectTypes, superInterface.getActualTypeArguments());
+ }
+ }
+
+ protected void assertTypeArgumentsAgainstRawReflect(Type[] reflectTypes, TypeInfo[] actualTypeArguments)
+ {
+ assertEquals(reflectTypes.length, actualTypeArguments.length);
+ for (int i = 0 ; i < reflectTypes.length ; i++)
+ {
+ assertTypeAgainstRawReflect(reflectTypes[i], actualTypeArguments[i]);
+ }
+ }
+
+ protected void assertTypeAgainstRawReflect(Type reflectType, TypeInfo actualType)
+ {
+ if (reflectType instanceof ParameterizedType)
+ {
+ ParameterizedType type = (ParameterizedType)reflectType;
+ Type rawType = type.getRawType();
+ assertTypeAgainstRawReflect(rawType, actualType);
+
+ assertTypeArgumentsAgainstRawReflect(type.getActualTypeArguments(), ((ClassInfo)actualType).getActualTypeArguments());
+ }
+ else if (reflectType instanceof Class)
+ {
+ Class<?> typeClass = (Class<?>)reflectType;
+ assertEquals(typeClass.getName(), actualType.getName());
+ }
+ else
+ {
+ //We might need to handle wildcards in which case we need to do something here
+ fail("Not yet implemented");
+ }
+ }
+ }
More information about the jboss-cvs-commits
mailing list