Buggy code:
private final Set < Class > ignoredDependencyTypes = new HashSet < Class > ( ) ; private final Set < Class > ignoredDependencyInterfaces = new HashSet < Class > ( ) ; private final Map < String , BeanWrapper > factoryBeanInstanceCache = new ConcurrentHashMap < String , BeanWrapper > ( ) ; private final Map < Class , PropertyDescriptor [ ] > filteredPropertyDescriptorsCache = new ConcurrentHashMap < Class , PropertyDescriptor [ ] > ( ) ; public AbstractAutowireCapableBeanFactory ( ) { } public AbstractAutowireCapableBeanFactory ( BeanFactory parentBeanFactory ) { } public void setInstantiationStrategy ( InstantiationStrategy instantiationStrategy ) { } protected InstantiationStrategy getInstantiationStrategy ( ) { } public void setParameterNameDiscoverer ( ParameterNameDiscoverer parameterNameDiscoverer ) { } protected ParameterNameDiscoverer getParameterNameDiscoverer ( ) { } public void setAllowCircularReferences ( boolean allowCircularReferences ) { } public void setAllowRawInjectionDespiteWrapping ( boolean allowRawInjectionDespiteWrapping ) { } public void ignoreDependencyType ( Class type ) { } public void ignoreDependencyInterface ( Class ifc ) { } @ Override public void copyConfigurationFrom ( ConfigurableBeanFactory otherFactory ) { } @ SuppressWarnings ( "unchecked" ) public < T > T createBean ( Class < T > beanClass ) throws BeansException { } public void autowireBean ( Object existingBean ) { } public Object configureBean ( Object existingBean , String beanName ) throws BeansException { } public Object resolveDependency ( DependencyDescriptor descriptor , String beanName ) throws BeansException { } public Object createBean ( Class beanClass , int autowireMode , boolean dependencyCheck ) throws BeansException { } public Object autowire ( Class beanClass , int autowireMode , boolean dependencyCheck ) throws BeansException { } public void autowireBeanProperties ( Object existingBean , int autowireMode , boolean dependencyCheck ) throws BeansException { } public void applyBeanPropertyValues ( Object existingBean , String beanName ) throws BeansException { } public Object initializeBean ( Object existingBean , String beanName ) { } public Object applyBeanPostProcessorsBeforeInitialization ( Object existingBean , String beanName ) throws BeansException { } public Object applyBeanPostProcessorsAfterInitialization ( Object existingBean , String beanName ) throws BeansException { } @ Override protected Object createBean ( final String beanName , final RootBeanDefinition mbd , final Object [ ] args ) throws BeanCreationException { } protected Object doCreateBean ( final String beanName , final RootBeanDefinition mbd , final Object [ ] args ) { } @ Override protected Class predictBeanType ( String beanName , RootBeanDefinition mbd , Class ... typesToMatch ) { } protected Class getTypeForFactoryMethod ( String beanName , RootBeanDefinition mbd , Class [ ] typesToMatch ) { Class factoryClass ; boolean isStatic = true ; String factoryBeanName = mbd . getFactoryBeanName ( ) ; if ( factoryBeanName != null ) { if ( factoryBeanName . equals ( beanName ) ) { throw new org . springframework . beans . factory . BeanDefinitionStoreException ( mbd . getResourceDescription ( ) , beanName , "factory-bean<seq2seq4repair_space>reference<seq2seq4repair_space>points<seq2seq4repair_space>back<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>bean<seq2seq4repair_space>definition" ) ; } factoryClass = getType ( factoryBeanName ) ; isStatic = false ; } else { factoryClass = resolveBeanClass ( mbd , beanName , typesToMatch ) ; } if ( factoryClass == null ) { return null ; } List < ValueHolder > argumentValues = mbd . getConstructorArgumentValues ( ) . getGenericArgumentValues ( ) ; Object [ ] args = new Object [ argumentValues . size ( ) ] ; for ( int i = 0 ; i < ( args . length ) ; i ++ ) { args [ i ] = argumentValues . get ( i ) . getValue ( ) ; } int minNrOfArgs = mbd . getConstructorArgumentValues ( ) . getArgumentCount ( ) ; Method [ ] candidates = ReflectionUtils . getUniqueDeclaredMethods ( factoryClass ) ; Set < Class < ? > > returnTypes = new HashSet < Class < ? > > ( 1 ) ; for ( Method factoryMethod : candidates ) { if ( ( ( ( Modifier . isStatic ( factoryMethod . getModifiers ( ) ) ) == isStatic ) && ( factoryMethod . getName ( ) . equals ( mbd . getFactoryMethodName ( ) ) ) ) && ( ( factoryMethod . getParameterTypes ( ) . length ) >= minNrOfArgs ) ) { <START_BUG> Class < ? > returnType = GenericTypeResolver . resolveParameterizedReturnType ( factoryMethod , args ) ; <END_BUG> if ( returnType != null ) { returnTypes . add ( returnType ) ; } } } if ( ( returnTypes . size ( ) ) == 1 ) { return returnTypes . iterator ( ) . next ( ) ; } else { return null ; } } @ Override protected Class < ? > getTypeForFactoryBean ( String beanName , RootBeanDefinition mbd ) { } protected Object getEarlyBeanReference ( String beanName , RootBeanDefinition mbd , Object bean ) { } private FactoryBean getSingletonFactoryBeanForTypeCheck ( String beanName , RootBeanDefinition mbd ) { } private FactoryBean getNonSingletonFactoryBeanForTypeCheck ( String beanName , RootBeanDefinition mbd ) { } protected void applyMergedBeanDefinitionPostProcessors ( RootBeanDefinition mbd , Class beanType , String beanName ) throws BeansException { } protected Object resolveBeforeInstantiation ( String beanName , RootBeanDefinition mbd ) { } protected Object applyBeanPostProcessorsBeforeInstantiation ( Class beanClass , String beanName ) throws BeansException { } protected BeanWrapper createBeanInstance ( String beanName , RootBeanDefinition mbd , Object [ ] args ) { } protected Constructor [ ] determineConstructorsFromBeanPostProcessors ( Class beanClass , String beanName ) throws BeansException { } protected BeanWrapper instantiateBean ( final String beanName , final RootBeanDefinition mbd ) { } protected BeanWrapper instantiateUsingFactoryMethod ( String beanName , RootBeanDefinition mbd , Object [ ] explicitArgs ) { } protected BeanWrapper autowireConstructor ( String beanName , RootBeanDefinition mbd , Constructor [ ] ctors , Object [ ] explicitArgs ) { } protected void populateBean ( String beanName , AbstractBeanDefinition mbd , BeanWrapper bw ) { } protected void autowireByName ( String beanName , AbstractBeanDefinition mbd , BeanWrapper bw , MutablePropertyValues pvs ) { } protected void autowireByType ( String beanName , AbstractBeanDefinition mbd , BeanWrapper bw , MutablePropertyValues pvs ) { } protected String [ ] unsatisfiedNonSimpleProperties ( AbstractBeanDefinition mbd , BeanWrapper bw ) { }

Fix:
Class < ? > returnType = GenericTypeResolver . resolveReturnTypeForGenericMethod ( factoryMethod , args ) ;