I use composite classes to group functionalities.
But, the class A (with composite A1), got inherited by B (with composite B1), and a behavior existent at A1 is going to be adapted at B1, but the final a1 must be a B1 instance for this to work.
Obs.: I have ways to make sure the composite instantiation happens properly (only by its composite partner).
Unable to assign a B1 object to a1 final field:
class finalFieldTestFails{
    class A1{
      A1(A a){}
    }
    class A{
      protected final A1 a1;
      A(){
        this.a1 = new A1(this);
      }
      A(A1 a1){
        this.a1 = a1;
      }
    }
    class B1 extends A1{
      B1(B b){
        super(b);
      }
    }
    class B extends A{
        //B(){ super.a1=new B1(this); } //FAIL: cant change final value
        //B(){super(new B1(this));} //FAIL: cant use 'this' or 'super'
    }
}
PS.: the answer shall not involve reflection security tricks if possible.
 
     
    