Thanks to a comment from @adranale, I found another answer in the "Java Language Specification" section on "Access Control" . I donβt think it should work that way, but the relevant text regarding the βprotectedβ reads
Let C be the class in which the protected member m is declared. Access is permitted only inside the body of subclass S of C.
The body of the class is all the code in braces. Class annotations are outside the curly braces, so they do not have access. Interestingly, this logic does not apply to annotations of methods, parameters, fields, or local variables that are inside the class body.
source share