When a bean is created with JavaConfig : with a @Bean method without the static modifier (there is another issue with the static modifier : #16756), the method postProcessBeforeInstantiation of InstantiationAwareBeanPostProcessor beans is not called.
See testcase attached
This method is correctly called when the bean is declared in an XML File.
This is one the causes of the troubles of the use of LazyInitTargetSourceCreator on JavaConfig (see #15140)
Indeed, we need to call postProcessBeforeInstantiation with a properly resolved bean type, like we do in other places. Up until this point, we simply always took the bean definition's raw bean class... which in the case of a static factory method was at least available (i.e. the class that the factory method is defined on), while for a non-static factory method, it wasn't even there (since they are delegated to a target factory bean by name) - which is why our algorithm didn't even call postProcessBeforeInstantiation (it required the bean class to be non-null). Both cases have been fixed for 4.1 now.