As for the problem itself: it really has nothing to do with inner classes (they are static in the example!). The problem is with this line:
Constrain<U,? super T> constrain = null;
which leads the type system to assume that there is a type that is a superclass of T, which also is a subclass of B (from the 'Constrain' class) - even though no such type could possibly exist! The evil trick is in the 'null' - even though a type with the stated constraints is impossible, and so no actual 'real' value of this generic type could exist, 'null' is part of all types, so the compiler can't see the problem.It really is a problem in the type system as defined in the standard, not just a compiler bug.