Consider a BeanDefinition with a FactoryBean that is registered programmatically. As it doesn't have a factory method, the code currently uses the target type's package to generate the code.
This does not work very well for FactoryBean target types, that are intermediate layers and should not be considered as a good target location for such a code. Perhaps BeanRegistrationCodeFragments#getTarget could have a check to see if the target type is such a factory bean?
See also #28809