-
Bug
-
Resolution: Won't Do
-
Major
-
None
-
2.4.0.Final
-
None
Following scenario:
public class MyService { @Inject private EntityManager em; // injects a WELD proxy public void test() { em.unwrap(org.hibernate.engine.spi.SessionImplementor.class).getFactory(); } }
Calling MyService#test results in a ClassCastException:
java.lang.ClassCastException: org.jboss.weldx.persistence.EntityManager$470189163$Proxy$_$$_WeldClientProxy cannot be cast to org.hibernate.engine.spi.SessionImplementor
This is becuase the condition at org.jboss.weld.bean.proxy.ProxyMethodHandler:103 causes the method handler to return self instead of this. The return type of EntityManager#unwrap is unbounded generic so
thisMethod.getReturnType().isAssignableFrom(self.getClass()))
always is true.
- is related to
-
WELD-1498 ClassCastException when proxied class return this
- Resolved