Buggy code:
public class CommonAnnotationBeanPostProcessorTests { @ Test public void testPostConstructAndPreDestroy ( ) { } @ Test public void testPostConstructAndPreDestroyWithPostProcessor ( ) { } @ Test public void testPostConstructAndPreDestroyWithApplicationContextAndPostProcessor ( ) { } @ Test public void testPostConstructAndPreDestroyWithManualConfiguration ( ) { } @ Test public void testPostProcessorWithNullBean ( ) { } @ Test public void testSerialization ( ) throws Exception { } @ Test public void testSerializationWithManualConfiguration ( ) throws Exception { } @ Test public void testResourceInjection ( ) { } @ Test public void testResourceInjectionWithPrototypes ( ) { } @ Test public void testResourceInjectionWithResolvableDependencyType ( ) { DefaultListableBeanFactory bf = new DefaultListableBeanFactory ( ) ; CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor ( ) ; bpp . setBeanFactory ( bf ) ; bf . addBeanPostProcessor ( bpp ) ; bf . registerBeanDefinition ( "annotatedBean" , new RootBeanDefinition ( CommonAnnotationBeanPostProcessorTests . ExtendedResourceInjectionBean . class , false ) ) ; bf . registerBeanDefinition ( "testBean4" , new RootBeanDefinition ( TestBean . class , false ) ) ; bf . registerResolvableDependency ( BeanFactory . class , bf ) ; <START_BUG> bf . registerResolvableDependency ( INestedTestBean . class , new ObjectFactory ( ) { <END_BUG> public Object getObject ( ) throws BeansException { return new NestedTestBean ( ) ; } } ) ; PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer ( ) ; Properties props = new Properties ( ) ; props . setProperty ( "tb" , "testBean4" ) ; ppc . setProperties ( props ) ; ppc . postProcessBeanFactory ( bf ) ; CommonAnnotationBeanPostProcessorTests . ExtendedResourceInjectionBean bean = ( ( CommonAnnotationBeanPostProcessorTests . ExtendedResourceInjectionBean ) ( bf . getBean ( "annotatedBean" ) ) ) ; INestedTestBean tb = bean . getTestBean6 ( ) ; assertNotNull ( tb ) ; CommonAnnotationBeanPostProcessorTests . ExtendedResourceInjectionBean anotherBean = ( ( CommonAnnotationBeanPostProcessorTests . ExtendedResourceInjectionBean ) ( bf . getBean ( "annotatedBean" ) ) ) ; assertNotSame ( anotherBean , bean ) ; assertNotSame ( anotherBean . getTestBean6 ( ) , tb ) ; String [ ] depBeans = bf . getDependenciesForBean ( "annotatedBean" ) ; assertEquals ( 1 , depBeans . length ) ; assertEquals ( "testBean4" , depBeans [ 0 ] ) ; } @ Test public void testResourceInjectionWithTwoProcessors ( ) { } @ Test public void testResourceInjectionFromJndi ( ) { } @ Test public void testExtendedResourceInjection ( ) { } @ Test public void testExtendedResourceInjectionWithOverriding ( ) { } @ Test public void testExtendedEjbInjection ( ) { } public static class AnnotatedInitDestroyBean { public boolean initCalled = false ; public boolean destroyCalled = false ; @ PostConstruct private void init ( ) { } @ PreDestroy private void destroy ( ) { } } public static class InitDestroyBeanPostProcessor implements DestructionAwareBeanPostProcessor { public Object postProcessBeforeInitialization ( Object bean , String beanName ) throws BeansException { } public Object postProcessAfterInitialization ( Object bean , String beanName ) throws BeansException { } public void postProcessBeforeDestruction ( Object bean , String beanName ) throws BeansException { } } public static class ResourceInjectionBean extends CommonAnnotationBeanPostProcessorTests . AnnotatedInitDestroyBean { public boolean init2Called = false ; public boolean init3Called = false ; public boolean destroy2Called = false ; public boolean destroy3Called = false ; @ Resource private TestBean testBean ; private TestBean testBean2 ; @ PostConstruct protected void init2 ( ) { } @ PostConstruct private void init ( ) { } @ PreDestroy protected void destroy2 ( ) { } @ PreDestroy private void destroy ( ) { } @ Resource public void setTestBean2 ( TestBean testBean2 ) { } public TestBean getTestBean ( ) { } public TestBean getTestBean2 ( ) { } } public static class ExtendedResourceInjectionBean extends CommonAnnotationBeanPostProcessorTests . ResourceInjectionBean { @ Resource ( name = "testBean4" , type = TestBean . class ) protected ITestBean testBean3 ; private ITestBean testBean4 ; @ Resource private INestedTestBean testBean5 ; private INestedTestBean testBean6 ; @ Resource private BeanFactory beanFactory ; @ Resource public void setTestBean2 ( TestBean testBean2 ) { } @ Resource ( name = "${tb}" , type = ITestBean . class ) private void setTestBean4 ( ITestBean testBean4 ) { } @ Resource public void setTestBean6 ( INestedTestBean testBean6 ) { } public ITestBean getTestBean3 ( ) { } public ITestBean getTestBean4 ( ) { } public INestedTestBean getTestBean5 ( ) { } public INestedTestBean getTestBean6 ( ) { } @ PostConstruct protected void init2 ( ) { } @ PreDestroy protected void destroy2 ( ) { } } public static class ExtendedEjbInjectionBean extends CommonAnnotationBeanPostProcessorTests . ResourceInjectionBean { @ EJB ( name = "testBean4" , beanInterface = TestBean . class ) protected ITestBean testBean3 ; private ITestBean testBean4 ; @ EJB private INestedTestBean testBean5 ; private INestedTestBean testBean6 ; @ Resource private BeanFactory beanFactory ; @ EJB public void setTestBean2 ( TestBean testBean2 ) { } @ EJB ( beanName = "testBean3" , beanInterface = ITestBean . class ) private void setTestBean4 ( ITestBean testBean4 ) { } @ EJB public void setTestBean6 ( INestedTestBean testBean6 ) { } public ITestBean getTestBean3 ( ) { } public ITestBean getTestBean4 ( ) { } @ PostConstruct protected void init2 ( ) { } @ PreDestroy protected void destroy2 ( ) { } } private static class NamedResourceInjectionBean { @ Resource ( name = "testBean9" ) private INestedTestBean testBean ; } private static class ConvertedResourceInjectionBean { @ Resource ( name = "value" ) private int value ; } private static class NullFactory { public static Object create ( ) { } } }

Fix:
bf . registerResolvableDependency ( INestedTestBean . class , new org . springframework . beans . factory . ObjectFactory < Object > ( ) {