[jboss-cvs] JBossAS SVN: r103267 - in projects/jboss-reflect/trunk/src: test/java/org/jboss/test/beaninfo/support and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 30 10:48:40 EDT 2010
Author: kabir.khan at jboss.com
Date: 2010-03-30 10:48:40 -0400 (Tue, 30 Mar 2010)
New Revision: 103267
Added:
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCovariantTypeVariableClassHierarchy1.java
Modified:
projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeVariableSpy.java
projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java
Log:
[JBREFLECT-5][JBREFLECT-107] Fix problem with determining interface typevariable bounds
Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeVariableSpy.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeVariableSpy.java 2010-03-30 14:47:15 UTC (rev 103266)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeVariableSpy.java 2010-03-30 14:48:40 UTC (rev 103267)
@@ -90,7 +90,16 @@
for (int i = 0 ; i < parameters.length ; i++)
{
if (parameters[i].getName().equals(tv.getName()))
- return parameters[i].getClassBound();
+ {
+ Type type = parameters[i].getClassBound();
+ if (type != null)
+ return type;
+ Type[] types = parameters[i].getInterfaceBound();
+ if (types != null && types.length > 0)
+ return types[0];
+
+ break;
+ }
}
return null;
Added: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCovariantTypeVariableClassHierarchy1.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCovariantTypeVariableClassHierarchy1.java (rev 0)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/support/BeanInfoCovariantTypeVariableClassHierarchy1.java 2010-03-30 14:48:40 UTC (rev 103267)
@@ -0,0 +1,60 @@
+/*
+* 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.beaninfo.support;
+
+import java.util.Collection;
+
+/**
+ * Replicates the <br/>
+ * BasicBeanAnnotationAdapter extends AbstractBeanAnnotationAdapter <br/>
+ * AbstractBeanAnnotationAdapter extends CommonAnnotationAdapter<AnnotationPlugin<?, ?>, MetaDataVisitor> <br/>
+ * CommonAnnotationAdapter<T extends MetaDataAnnotationPlugin<?, ?>, U> <br/>
+ * <br/>
+ * type hierarchy that was causing problems when testing kernel with the javassist type infos
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BeanInfoCovariantTypeVariableClassHierarchy1
+{
+
+ public static class Class1 extends Class2
+ {
+ @Override
+ public void setProperty(Collection<?> coll)
+ {
+ }
+ }
+
+ public static class Class2 extends Class3<Collection<?>>
+ {
+ }
+
+ public static class Class3<T extends Collection<?>>
+ {
+ public void setProperty(T coll)
+ {
+ }
+ }
+
+}
+
Modified: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java 2010-03-30 14:47:15 UTC (rev 103266)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java 2010-03-30 14:48:40 UTC (rev 103267)
@@ -22,13 +22,15 @@
package org.jboss.test.beaninfo.test;
import java.lang.annotation.Annotation;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import junit.framework.Test;
+
+import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.reflect.spi.AnnotationValue;
import org.jboss.test.beaninfo.support.BeanInfoAnnotatedGetterAndSetter;
import org.jboss.test.beaninfo.support.BeanInfoAnnotatedGetterAndSetterSimpleMerge;
@@ -40,40 +42,41 @@
import org.jboss.test.beaninfo.support.BeanInfoAnnotation2;
import org.jboss.test.beaninfo.support.BeanInfoBooleanProperties;
import org.jboss.test.beaninfo.support.BeanInfoConstructors;
+import org.jboss.test.beaninfo.support.BeanInfoCovariantTypeVariableClassHierarchy1;
import org.jboss.test.beaninfo.support.BeanInfoDefaultConstructor;
import org.jboss.test.beaninfo.support.BeanInfoDoubleCovariantImpl;
import org.jboss.test.beaninfo.support.BeanInfoEmpty;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo2;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo3;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo4;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo5;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo6;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo7;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo8;
+import org.jboss.test.beaninfo.support.BeanInfoFields;
import org.jboss.test.beaninfo.support.BeanInfoGenericGetterAndSetter;
import org.jboss.test.beaninfo.support.BeanInfoGenericGetterOnly;
import org.jboss.test.beaninfo.support.BeanInfoGenericInconsistentTypes;
import org.jboss.test.beaninfo.support.BeanInfoGenericInterfaceImpl;
import org.jboss.test.beaninfo.support.BeanInfoGenericSetterOnly;
+import org.jboss.test.beaninfo.support.BeanInfoGetterAndField;
+import org.jboss.test.beaninfo.support.BeanInfoGetterAndField2;
import org.jboss.test.beaninfo.support.BeanInfoGetterAndSetter;
+import org.jboss.test.beaninfo.support.BeanInfoGetterAndSetter2;
import org.jboss.test.beaninfo.support.BeanInfoGetterOnly;
import org.jboss.test.beaninfo.support.BeanInfoInconsistentTypes;
import org.jboss.test.beaninfo.support.BeanInfoInterface;
+import org.jboss.test.beaninfo.support.BeanInfoMethods;
import org.jboss.test.beaninfo.support.BeanInfoParameterConstructor;
import org.jboss.test.beaninfo.support.BeanInfoProperties;
+import org.jboss.test.beaninfo.support.BeanInfoSetterAndField;
+import org.jboss.test.beaninfo.support.BeanInfoSetterAndField2;
import org.jboss.test.beaninfo.support.BeanInfoSetterOnly;
import org.jboss.test.beaninfo.support.BeanInfoUpperPropertyName;
-import org.jboss.test.beaninfo.support.BeanInfoMethods;
-import org.jboss.test.beaninfo.support.BeanInfoGetterAndField;
-import org.jboss.test.beaninfo.support.BeanInfoFields;
+import org.jboss.test.beaninfo.support.SubBeanInfoGetterAndField;
import org.jboss.test.beaninfo.support.SubBeanInfoGetterAndSetter;
-import org.jboss.test.beaninfo.support.BeanInfoGetterAndSetter2;
-import org.jboss.test.beaninfo.support.BeanInfoGetterAndField2;
-import org.jboss.test.beaninfo.support.SubBeanInfoGetterAndField;
-import org.jboss.test.beaninfo.support.BeanInfoSetterAndField;
-import org.jboss.test.beaninfo.support.BeanInfoSetterAndField2;
import org.jboss.test.beaninfo.support.SubBeanInfoSetterAndField;
-import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo;
-import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo2;
-import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo3;
-import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo4;
-import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo5;
-import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo6;
-import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo7;
-import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo8;
/**
* BeanInfo Test Case.
@@ -353,6 +356,16 @@
testBeanAnnotations(BeanInfoAnnotatedGetterAndSetterSimpleMerge.class, new String[] { "something" }, new Class<?>[] {BeanInfoAnnotation1.class, BeanInfoAnnotation2.class});
}
+ public void testCovariantBeanInfoWithTypeVariableInHierarchy() throws Throwable
+ {
+ BeanInfo beanInfo = getBeanInfo(BeanInfoCovariantTypeVariableClassHierarchy1.Class1.class);
+ assertNotNull(beanInfo);
+ PropertyInfo property = beanInfo.getProperty("property");
+ assertNotNull(property);
+ assertEquals(Collection.class.getName(), property.getType().getName());
+
+ }
+
protected void testBean(Class<?> clazz, String[] beanNames) throws Throwable
{
for (BeanAccessMode mode : BeanAccessMode.values())
More information about the jboss-cvs-commits
mailing list