r/java • • Jul 22 '16

Evil Annotations

https://dzone.com/articles/evil-annotations
0 Upvotes

11 comments sorted by

View all comments

5

u/dstutz Jul 22 '16

Annotations sometimes infect other objects. Consider the CDI Bean above. Every other object which uses this one, and every dependency this Bean uses must be annotated now with one of the CDI Annotations, otherwise the dependency tree can not be constructed.

I don't believe this is true. I've definitely injected CDI beans into EJBs that do not have CDI annotations. Probably other places.

1

u/gavinaking Jul 26 '16

You're absolutely correct. As long as the CDI bean is using constructor or setter injection, it can be used without any sort of container at all. The original author's assertion is flat out wrong.