Affects: all version
I try to know the beanClass of BeanDefinition, however, I found some subClass of BeanDefinition has no beanClass.
Such as ConfigurationClassBeanDefinition in ConfigurationClassBeanDefinitionReader, when ConfigurationClassPostProcessor parse @Bean method to a BeanDefinition(ConfigurationClassBeanDefinition), whose beanClass field is null.
So far as I know, beanClass stand for it's bean type.
I wan to know why beanClass in BeanDefinition can be null, and how I get it's bean type from some of it's subClass.
Comment From: jhoeller
AbstractBeanDefinition.getBeanClass() contains a resolved bean class name as specified in the original bean definition; this is just indirectly related to the bean's actual runtime type. A bean definition may point to a specific factory method on that bean class, returning a different type of bean, or it might declare a FactoryBean class for a different object type. The recommended way to find out about the actual runtime type of a particular bean is a BeanFactory.getType call for the specified bean name; this takes all of the above cases into account and returns the type of object that a BeanFactory.getBean call is going to return for the same bean name.
I've turned this into a documentation ticket since we should really have a bold note on this in the javadoc as well as the reference documentation. This is not as obvious as it should be.