I don't think "Can't be accessed from outside this class" is
controversial. The issue is what constitutes "this class". If code in a
nested class were considered to be in a different class from the code in
the top level class surrounding it then nested classes would be a lot
One could devise an asymetrical approach, in which code in nested
classes is considered to be both inside the nested class and also inside
the top level class, while code in the top level class outside the body
of the nested class is considered to be in a different class from the
nested class, but that would make the rules and their enforcement more
It's not clear that the extra complexity would add much to the main
benefit of "private" data, limiting the scope of code that has to be
examined to find all references to it.
6.6.1 Determining Accessibility
* A package is always accessible.
* If a class or interface type is declared public, then it may be accessed by any code, provided that the compilation unit (�7.3) in which it is declared is observable. If a top level class or interface type is not declared public, then it may be accessed only from within the package in which it is declared.
* An array type is accessible if and only if its element type is accessible.
* A member (class, interface, field, or method) of a reference (class, interface, or array) type or a constructor of a class type is accessible only if the type is accessible and the member or constructor is declared to permit access:
o If the member or constructor is declared public, then access is permitted. All members of interfaces are implicitly public.
o Otherwise, if the member or constructor is declared protected, then access is permitted only when one of the following is true:
# Access to the member or constructor occurs from within the package containing the class in which the protected member or constructor is declared.
# Access is correct as described in �6.6.2.
o Otherwise, if the member or constructor is declared private, then access is permitted if and only if it occurs within the body of the top level class (�7.6) that encloses the declaration of the member.
o Otherwise, we say there is default access, which is permitted only when the access occurs from within the package in which the type is declared.