- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    8
                    JLS 15.12.4.3 describes the accessibility check for protected methods as follows (compare JVMS 5.4.4):
"If m is protected, then m is accessible if and only if either T is in the same package as C, or C is T or a subclass of T."
This is incorrect, because it fails to distinguish between the _qualifying type_, T, and the _declaring type_ (call it D). In general, T inherits m from D. The package that controls access is that package of D, not the package of T; and C must be a subclass of D, not necessarily T. (The same comment applies to the package access rule.)
The rule also fails to mention the additional restriction that the receiver of a non-static invocation be a subtype of C. That is, for non-static invocations, T is a subclass of C.
"If m is protected, then m is accessible if and only if either T is in the same package as C, or C is T or a subclass of T."
This is incorrect, because it fails to distinguish between the _qualifying type_, T, and the _declaring type_ (call it D). In general, T inherits m from D. The package that controls access is that package of D, not the package of T; and C must be a subclass of D, not necessarily T. (The same comment applies to the package access rule.)
The rule also fails to mention the additional restriction that the receiver of a non-static invocation be a subtype of C. That is, for non-static invocations, T is a subclass of C.
- relates to
- 
                    JDK-8033790 6.6.2: Protected accessibility check inconsistent with longstanding javac behavior -           
- Closed
 
-         
- 
                    JDK-8061877 15.12.4.3: Description of nested class access checks is incorrect -           
- Closed
 
-