CdiExtension
incorrectly uses beanClass
as means to determine implementation class of a bean
#5159
Labels
CdiExtension
incorrectly uses beanClass
as means to determine implementation class of a bean
#5159
Describe the bug
In the current state of
CdiExtension
, it usesBean#getBeanClass()
to derive the impl class of a bean. See this code.This is wrong because there can be three types of beans and this only works as expected with one of them:
beanClass
is equal to the impl class of the beanbeanClass
equals to the class of the bean declaring the producer which can be a completely different beanbeanClass
in this case and users can set arbitrary values. Weld defaults to the class of the CDI extension that declared the bean. Nonetheless, user can pick any class here (as seen in CDI bean attributebeanClass
is not used correctly in CDI extension and producers #5157)I am far from being expert in Mojarra, so maybe this is fine and the bean will always be a managed bean; I'll let someone else decide that. I just wanted to point this out since I noticed it. It could be that this is perfectly fine.
I am also not sure what would be a good replacement because being able to derive the exact impl class (if that's the requirement here?) from a bean is beyond CDI extension capabilities simply because you can either (a) limit bean types and (b) with producers you can choose to instantiate one of multiple subclasses during runtime and CDI cannot know which.
The text was updated successfully, but these errors were encountered: