[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: UnwrapValueUnitTestCase.testCollectionUnwrap failure on
adrian@jboss.org
do-not-reply at jboss.com
Thu Nov 20 09:22:50 EST 2008
I think I've found A problem? But I'm still not sure
if this is the cause of the problem seen.
The issue is that DefaultMetaValueFactory::unwrapCollection() has this
| BeanInfo collectionInfo;
| // null is not instance of
| if (type instanceof ClassInfo)
| {
| collectionInfo = configuration.getBeanInfo(type);
| }
|
Which if you look in AbstractBeanInfoFactory has this caching
| public BeanInfo getBeanInfo(ClassAdapter classAdapter, BeanAccessMode accessMode)
| {
| if (classAdapter == null)
| throw new IllegalArgumentException("Null class adapter.");
| if (accessMode == null)
| accessMode = BeanAccessMode.STANDARD;
|
| synchronized (cache)
| {
| ClassLoader cl = classAdapter.getClassLoader();
| ClassInfo classInfo = classAdapter.getClassInfo();
| String className = classInfo.getName();
| Map<String, Map<BeanAccessMode, BeanInfo>> map = cache.get(cl);
|
The issue being that for ParameterizedClassInfo, classInfo.getName()
effectively maps to getRawType().getName() (actually this is done
through the super construction of the DelegateClassInfo).
Then the next step in unwrapCollection is to use the ClassInfo of the
BeanInfo to get the componentType
| ClassInfo classInfo = collectionInfo.getClassInfo();
| Collection collection = (Collection)createNewInstance(collectionInfo);
|
| TypeInfo componentType = classInfo.getComponentType();
|
which should be the raw type?
Clearly, the caching in AbstractBeanInfoFactory shouldn't be using
classInfo.getName() in its caching.
Or if it is going to use that, then ParameterizedClassInfo needs to override getName()
to return the generic name (but I'm not sure what that would break?).
Parameterized types should get their own BeanInfo, e.g.
| // This is a parameterized type with one Object property "something"
| public class GenericBean<T>
| {
| private T t;
| public T getSomething() { return t; }
| public void setSomething() { this.t = t; }
| }
|
| // This is a parameterized type with one **String** property "something"
| public class StringBean extends GenericBean<String> {}
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4190899#4190899
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4190899
More information about the jboss-dev-forums
mailing list