Relevant sections of the Java Language Specification should be:
ยง8.1.4: [...] The ClassType type must indicate the available class type (ยง6.6), or a compile-time error occurs.
ยง6.6.1: [...] A member (class, interface, field or method) of a reference type (class, interface or array) or a class type constructor is available only if the type is available and the member or constructor is declared to allow access :
- If a member or constructor is declared public, access is allowed. All interface members are implicitly public. [...]
- Otherwise, if a member or constructor is declared private, access is allowed if and only if it occurs inside the body of a top-level class (ยง7.6), which includes the declaration of a member or constructor.
Since ClassType is not part of the class body, B.Secret not available at this location, therefore A<B.Secret> not available, therefore a compile-time error should occur.
Rasmus faber
source share