Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8033466

15.12.4.3: Clean up description of protected access

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8
    • specification

      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.

            abuckley Alex Buckley
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: