[jboss-dev-forums] [Design the new POJO MicroContainer] - Is ParameterizedClassInfo serialization broken

alesj do-not-reply at jboss.com
Fri Nov 21 05:49:55 EST 2008


Looking at ParameterizedClassInfo, I have a few doubts about its serialization.


  | public class ParameterizedClassInfo extends DelegateClassInfo
  | {
  |    /** The serialVersionUID */
  |    private static final long serialVersionUID = 2;
  |    
  |    /** The factory */
  |    protected transient IntrospectionTypeInfoFactoryImpl factory;
  |    
  |    /** The parameterized type */
  |    transient ParameterizedType parameterizedType;
  |    
  |    /** The owner type */
  |    private TypeInfo ownerType = ClassInfoImpl.UNKNOWN_TYPE;
  |    
  |    /** The type arguments */
  |    private TypeInfo[] typeArguments = ClassInfoImpl.UNKNOWN_TYPES;
  |    
  |    /** The component type */
  |    private transient TypeInfo componentType = ClassInfoImpl.UNKNOWN_TYPE;
  |    
  |    /** The key type */
  |    private transient TypeInfo keyType = ClassInfoImpl.UNKNOWN_TYPE;
  |    
  |    /** The key type */
  |    private transient TypeInfo valueType = ClassInfoImpl.UNKNOWN_TYPE;
  |    
  |    /**
  |     * Create a new ParameterizedClassInfo.
  |     *
  |     * @param factory the factory
  |     * @param delegate the raw array info
  |     * @param parameterizedType the parameterized  type
  |     */
  |    public ParameterizedClassInfo(IntrospectionTypeInfoFactoryImpl factory, ClassInfo delegate, ParameterizedType parameterizedType)
  |    {
  |       super(delegate);
  |       this.factory = factory;
  |       this.delegate = delegate;
  |       this.parameterizedType = parameterizedType;
  |    }
  | 
  |    public TypeInfoFactory getTypeInfoFactory()
  |    {
  |       return factory;
  |    }
  | 
  |    @Override
  |    public TypeInfo[] getActualTypeArguments()
  |    {
  |       if (typeArguments == ClassInfoImpl.UNKNOWN_TYPES)
  |          typeArguments = factory.getActualTypeArguments(this);
  |       return typeArguments;
  |    }
  | 
  |    @Override
  |    public TypeInfo getOwnerType()
  |    {
  |       if (ownerType == ClassInfoImpl.UNKNOWN_TYPE)
  |          ownerType = factory.getOwnerType(this);
  |       return ownerType;
  |    }
  | 
  |    @Override
  |    public ClassInfo getRawType()
  |    {
  |       return delegate;
  |    }
  | 
  |    @Override
  |    public TypeInfo getComponentType()
  |    {
  |       if (componentType == ClassInfoImpl.UNKNOWN_TYPE)
  |          componentType = factory.getComponentType(this);
  |       return componentType;
  |    }
  | 
  |    @Override
  |    public TypeInfo getKeyType()
  |    {
  |       if (keyType == ClassInfoImpl.UNKNOWN_TYPE);
  |          keyType = factory.getKeyType(this);
  |       return keyType;
  |    }
  | 
  |    @Override
  |    public TypeInfo getValueType()
  |    {
  |       if (valueType == ClassInfoImpl.UNKNOWN_TYPE)
  |          valueType = factory.getValueType(this);
  |       return valueType;
  |    }
  | 

After serialization, componentType, keyType, valueType are all gonna be null == not ClassInfoImpl.UNKNOWN_TYPE,
hence null would be returned.
Even if they were equal to ClassInfoImpl.UNKNOWN_TYPE,
NPE would be thrown due to factory being null.

Is this expected behavior (the first, not NPE :-))?

ps: just saw that there is ';' at the end of 'if' in getKeyType :-)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4191191#4191191

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4191191



More information about the jboss-dev-forums mailing list