2 Replies Latest reply on Feb 7, 2010 9:10 PM by Matthieu Chase Heimer

    CDI spec statement about Typecasting

    Matthieu Chase Heimer Newbie

      Section 2.2.3. Typecasting between bean types from the final spec implies that given:



      public class BizImp implements Biz {}



      The following two lines would be valid:



      @Inject Biz iRef;
      @Inject BizImp cRef;





      But that in the client I could not latter do a:



      BizImp ref = (BizImp)iRef;




      I only see this typecasting limitation in the final spec and not in the Weld docs. It actually works in Weld and in fact the spec says might result in an exception at runtime.


      This seems like such an arbitrary and silly limitation that is bound to cause problems porting applications across CDI implementations. What is the reasoning behind this constraint?