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

8.4.6.1 Overriding is unclear.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.4.0
    • Component/s: specification
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.4
    • CPU:
      generic
    • OS:
      solaris_8
    • Verification:
      Verified

      Description

      In 8.6.4.1, it says

      An instance method m1 declared in a class C overrides another method with the same signature, m2, declared in class A if
      both

        1.C is a subclass of A.
        2.Either
           o m2 is non-private and accessible from C, or
           o m1 overrides a method m3, m3 distinct from m1,
      m3 distinct from m2, such that m3 overrides m2.

      My question has to do with the phrase "accessible from C". Does this
      mean accessible in code within the class C when accessing as a member of A,
      or does it mean is an accessible member of C? There is a difference when the
      member is not inherited into C. The resolution of 4362349 depends on the
      interpretation of this phrase.

      Recent discussions have suggested that this means either

      (1) m2 is a member of C accessible to code in C, or
      (2) m2, as a member of A, is accessible to code in C

      Neither definition is very satisfying. If definition (1) is the
      one we should use in the compiler, then 4362349 is indeed a compiler bug
      and I know how to fix it. But then the following program will
      be a compile-time error:

      package p1;
      abstract class A {
      abstract protected f();
      }

      package p2;
      class C extends p1.A {
      protected f() {}
      }

      The compiler will complain that class C should be declared abstract
      because it doesn't override f() in A. That's because A.f isn't
      accessible in C because the qualifying type, A, isn't C (JLS 6.6.2.1).

      So I'm back to the drawing board trying to understand 8.6.4.1.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gbrachasunw Gilad Bracha (Inactive)
                Reporter:
                gafter Neal Gafter
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: