@@ -135,21 +135,21 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
135135 * Dependency types to ignore on dependency check and autowire, as Set of
136136 * Class objects: for example, String. Default is none.
137137 */
138- private final Set <Class > ignoredDependencyTypes = new HashSet <Class >();
138+ private final Set <Class <?>> ignoredDependencyTypes = new HashSet <Class <?> >();
139139
140140 /**
141141 * Dependency interfaces to ignore on dependency check and autowire, as Set of
142142 * Class objects. By default, only the BeanFactory interface is ignored.
143143 */
144- private final Set <Class > ignoredDependencyInterfaces = new HashSet <Class >();
144+ private final Set <Class <?>> ignoredDependencyInterfaces = new HashSet <Class <?> >();
145145
146146 /** Cache of unfinished FactoryBean instances: FactoryBean name --> BeanWrapper */
147147 private final Map <String , BeanWrapper > factoryBeanInstanceCache =
148148 new ConcurrentHashMap <String , BeanWrapper >(16 );
149149
150150 /** Cache of filtered PropertyDescriptors: bean Class -> PropertyDescriptor array */
151- private final Map <Class , PropertyDescriptor []> filteredPropertyDescriptorsCache =
152- new ConcurrentHashMap <Class , PropertyDescriptor []>(64 );
151+ private final Map <Class <?> , PropertyDescriptor []> filteredPropertyDescriptorsCache =
152+ new ConcurrentHashMap <Class <?> , PropertyDescriptor []>(64 );
153153
154154
155155 /**
@@ -506,7 +506,7 @@ protected Object doCreateBean(final String beanName, final RootBeanDefinition mb
506506 logger .debug ("Eagerly caching bean '" + beanName +
507507 "' to allow for resolving potential circular references" );
508508 }
509- addSingletonFactory (beanName , new ObjectFactory () {
509+ addSingletonFactory (beanName , new ObjectFactory < Object > () {
510510 public Object getObject () throws BeansException {
511511 return getEarlyBeanReference (beanName , mbd , bean );
512512 }
@@ -634,9 +634,9 @@ protected Class<?> getTypeForFactoryMethod(String beanName, RootBeanDefinition m
634634
635635 // If all factory methods have the same return type, return that type.
636636 // Can't clearly figure out exact method due to type converting / autowiring!
637+ Class <?> commonType = null ;
637638 int minNrOfArgs = mbd .getConstructorArgumentValues ().getArgumentCount ();
638639 Method [] candidates = ReflectionUtils .getUniqueDeclaredMethods (factoryClass );
639- Set <Class <?>> returnTypes = new HashSet <Class <?>>(1 );
640640 for (Method factoryMethod : candidates ) {
641641 if (Modifier .isStatic (factoryMethod .getModifiers ()) == isStatic &&
642642 factoryMethod .getName ().equals (mbd .getFactoryMethodName ()) &&
@@ -669,7 +669,7 @@ protected Class<?> getTypeForFactoryMethod(String beanName, RootBeanDefinition m
669669 Class <?> returnType = AutowireUtils .resolveReturnTypeForFactoryMethod (
670670 factoryMethod , args , getBeanClassLoader ());
671671 if (returnType != null ) {
672- returnTypes . add (returnType );
672+ commonType = ClassUtils . determineCommonAncestor (returnType , commonType );
673673 }
674674 }
675675 catch (Throwable ex ) {
@@ -679,14 +679,14 @@ protected Class<?> getTypeForFactoryMethod(String beanName, RootBeanDefinition m
679679 }
680680 }
681681 else {
682- returnTypes . add (factoryMethod .getReturnType ());
682+ commonType = ClassUtils . determineCommonAncestor (factoryMethod .getReturnType (), commonType );
683683 }
684684 }
685685 }
686686
687- if (returnTypes . size () == 1 ) {
687+ if (commonType != null ) {
688688 // Clear return type found: all factory methods return same type.
689- return returnTypes . iterator (). next () ;
689+ return commonType ;
690690 }
691691 else {
692692 // Ambiguous return types found: return null to indicate "not determinable".
@@ -788,11 +788,11 @@ protected Object getEarlyBeanReference(String beanName, RootBeanDefinition mbd,
788788 * @return the FactoryBean instance, or {@code null} to indicate
789789 * that we couldn't obtain a shortcut FactoryBean instance
790790 */
791- private FactoryBean getSingletonFactoryBeanForTypeCheck (String beanName , RootBeanDefinition mbd ) {
791+ private FactoryBean <?> getSingletonFactoryBeanForTypeCheck (String beanName , RootBeanDefinition mbd ) {
792792 synchronized (getSingletonMutex ()) {
793793 BeanWrapper bw = this .factoryBeanInstanceCache .get (beanName );
794794 if (bw != null ) {
795- return (FactoryBean ) bw .getWrappedInstance ();
795+ return (FactoryBean <?> ) bw .getWrappedInstance ();
796796 }
797797 if (isSingletonCurrentlyInCreation (beanName )) {
798798 return null ;
@@ -812,7 +812,7 @@ private FactoryBean getSingletonFactoryBeanForTypeCheck(String beanName, RootBea
812812 // Finished partial creation of this bean.
813813 afterSingletonCreation (beanName );
814814 }
815- FactoryBean fb = getFactoryBean (beanName , instance );
815+ FactoryBean <?> fb = getFactoryBean (beanName , instance );
816816 if (bw != null ) {
817817 this .factoryBeanInstanceCache .put (beanName , bw );
818818 }
@@ -829,7 +829,7 @@ private FactoryBean getSingletonFactoryBeanForTypeCheck(String beanName, RootBea
829829 * @return the FactoryBean instance, or {@code null} to indicate
830830 * that we couldn't obtain a shortcut FactoryBean instance
831831 */
832- private FactoryBean getNonSingletonFactoryBeanForTypeCheck (String beanName , RootBeanDefinition mbd ) {
832+ private FactoryBean <?> getNonSingletonFactoryBeanForTypeCheck (String beanName , RootBeanDefinition mbd ) {
833833 if (isPrototypeCurrentlyInCreation (beanName )) {
834834 return null ;
835835 }
@@ -972,7 +972,7 @@ protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd
972972 }
973973
974974 // Need to determine the constructor...
975- Constructor [] ctors = determineConstructorsFromBeanPostProcessors (beanClass , beanName );
975+ Constructor <?> [] ctors = determineConstructorsFromBeanPostProcessors (beanClass , beanName );
976976 if (ctors != null ||
977977 mbd .getResolvedAutowireMode () == RootBeanDefinition .AUTOWIRE_CONSTRUCTOR ||
978978 mbd .hasConstructorArgumentValues () || !ObjectUtils .isEmpty (args )) {
@@ -992,14 +992,14 @@ protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd
992992 * @throws org.springframework.beans.BeansException in case of errors
993993 * @see org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor#determineCandidateConstructors
994994 */
995- protected Constructor [] determineConstructorsFromBeanPostProcessors (Class <?> beanClass , String beanName )
995+ protected Constructor <?> [] determineConstructorsFromBeanPostProcessors (Class <?> beanClass , String beanName )
996996 throws BeansException {
997997
998998 if (beanClass != null && hasInstantiationAwareBeanPostProcessors ()) {
999999 for (BeanPostProcessor bp : getBeanPostProcessors ()) {
10001000 if (bp instanceof SmartInstantiationAwareBeanPostProcessor ) {
10011001 SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor ) bp ;
1002- Constructor [] ctors = ibp .determineCandidateConstructors (beanClass , beanName );
1002+ Constructor <?> [] ctors = ibp .determineCandidateConstructors (beanClass , beanName );
10031003 if (ctors != null ) {
10041004 return ctors ;
10051005 }
@@ -1070,7 +1070,7 @@ protected BeanWrapper instantiateUsingFactoryMethod(
10701070 * @return BeanWrapper for the new instance
10711071 */
10721072 protected BeanWrapper autowireConstructor (
1073- String beanName , RootBeanDefinition mbd , Constructor [] ctors , Object [] explicitArgs ) {
1073+ String beanName , RootBeanDefinition mbd , Constructor <?> [] ctors , Object [] explicitArgs ) {
10741074
10751075 return new ConstructorResolver (this ).autowireConstructor (beanName , mbd , ctors , explicitArgs );
10761076 }
0 commit comments