diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java index 0fccf96455..0fa9a6a551 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -403,16 +403,29 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess /** * Specify the class for this bean. + * @see #setBeanClassName(String) */ public void setBeanClass(@Nullable Class> beanClass) { this.beanClass = beanClass; } /** - * Return the class of the wrapped bean (assuming it is resolved already). - * @return the bean class (never {@code null}) + * Return the specified class of the bean definition (assuming it is resolved already). + *
NOTE: This is an initial class reference as declared in the bean metadata
+ * definition, potentially combined with a declared factory method or a
+ * {@link org.springframework.beans.factory.FactoryBean} which may lead to a different
+ * runtime type of the bean, or not being set at all in case of an instance-level
+ * factory method (which is resolved via {@link #getFactoryBeanName()} instead).
+ * Do not use this for runtime type introspection of arbitrary bean definitions.
+ * The recommended way to find out about the actual runtime type of a particular bean
+ * is a {@link org.springframework.beans.factory.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 {@link org.springframework.beans.factory.BeanFactory#getBean}
+ * call is going to return for the same bean name.
+ * @return the resolved bean class (never {@code null})
* @throws IllegalStateException if the bean definition does not define a bean class,
* or a specified bean class name has not been resolved into an actual Class yet
+ * @see #getBeanClassName()
* @see #hasBeanClass()
* @see #setBeanClass(Class)
* @see #resolveBeanClass(ClassLoader)
diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc
index d1dea79ddc..7ab620ef54 100644
--- a/src/docs/asciidoc/core/core-beans.adoc
+++ b/src/docs/asciidoc/core/core-beans.adoc
@@ -346,8 +346,8 @@ bean definition files through an `importBeans` directive.
=== Using the Container
The `ApplicationContext` is the interface for an advanced factory capable of maintaining
-a registry of different beans and their dependencies. By using the method `T getBean(String
-name, Class