Details
-
Bug
-
Resolution: Done
-
Major
-
1.1.2.Final
-
None
Description
CDI 1.0 section 11.3.1 Obtaining a contextual reference for a bean states:
"If the given type is not a bean type of the given bean, an IllegalArgumentException is thrown."
However no such exception is thrown. Refer to CDI TCK test [1].
After inspecting the source code I suppose the problem is probably related to following part of org.jboss.weld.manager.BeanManagerImpl.getReference(Bean<?>, Type, CreationalContext<?>):
if (!Reflections.isAssignableFrom(bean.getTypes(), beanType)) { throw new IllegalArgumentException(SPECIFIED_TYPE_NOT_BEAN_TYPE, beanType, bean ); }
All beans have the bean type java.lang.Object (2.2. Bean types) - since java.lang.Object is assignable from any class Reflections.isAssignableFrom(bean.getTypes(), beanType) will always return true.