Kabir Khan [
http://community.jboss.org/people/kabir.khan%40jboss.com] replied to the
discussion
"JBREFLECT-5 - Implementing generics in JavassistClassInfo"
To view the discussion, visit:
http://community.jboss.org/message/539885#539885
--------------------------------------------------------------
I have tried turning off caching for these parameterized ClassInfos,
which causes some of the tests to fail. From what I can see fixing them means having to
adjust some of the tests to use assertEquals() instead of assertSame() for parameterized
ClassInfos. I think this is necessary, and that the idea of enforcing object equality for
parameterized ClassInfos is a misunderstanding :-)
Apart from this local fix in
BeanInfoCacheTestCase, all the other places that test object equality for parameterized
class infos are in tests written by me as part of JBREFLECT-5, so I think I am safe to
readjust the tests
[kabir ~/sourcecontrol/jboss-reflect/trunk/jboss-reflect]
$svn diff src/test/
Index: src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java
===================================================================
--- src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java (revision
104118)
+++ src/test/java/org/jboss/test/beaninfo/test/BeanInfoCacheTestCase.java (working
copy)
@@ -125,16 +125,45 @@
{
BeanInfo beanInfo = getConfiguration().getBeanInfo(typeInfo);
ClassInfo typeInfo2 = beanInfo.getClassInfo();
- assertSame(typeInfo, typeInfo2);
+ assertClassInfos(typeInfo, typeInfo2);
}
-
+
private void assertClassInfo(ClassInfo typeInfo, String className, ClassLoader cl)
throws Exception
{
BeanInfo beanInfo = getConfiguration().getBeanInfo(className, cl);
ClassInfo typeInfo2 = beanInfo.getClassInfo();
- assertSame(typeInfo, typeInfo2);
+ assertClassInfos(typeInfo, typeInfo2);
}
+ private void assertClassInfos(TypeInfo typeA, TypeInfo typeB)
+ {
+ ClassInfo classA = assertInstanceOf(typeA, ClassInfo.class);
+ ClassInfo classB = assertInstanceOf(typeB, ClassInfo.class);
+
+ if (classA.getRawType() == classA)
+ assertSame(classA, classB);
+ else
+ {
+ assertEquals(classA, classB);
+ TypeInfo[] argsA = classA.getActualTypeArguments();
+ TypeInfo[] argsB = classB.getActualTypeArguments();
+
+ if (argsA != null)
+ assertNotNull(argsB);
+ if (argsB != null)
+ assertNotNull(argsA);
+ if (argsA == null)
+ {
+ assertNull(argsB);
+ return;
+ }
+
+ assertEquals(argsA.length, argsB.length);
+ for (int i = 0 ; i < argsA.length ; i++)
+ assertClassInfos(argsA[i], argsB[i]);
+ }
+ }
+
@SuppressWarnings("unchecked")
protected Type getType(String type, Class<?> clazz) throws Exception
{
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/539885#539885]
Start a new discussion in JBoss Microcontainer Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]