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

default access modifier unimplementable for classes' interfaces

XMLWordPrintable

    • generic
    • generic

      The default (package-level) access for methods detailed in JLS 1st ed. Section 6.6.5 is not working properly for implemented interfaces. Code samples in "Comments" section consist of two interfaces defining methods with default access and three classes implementing those interfaces.

      When any implementing class in the test suite is compiled, each of them implementing methods with the same signature and same (default) access as the definition found in the interface, javac in JDK 1.2 on Solaris or Windows NT complains that:

      "The method <signature> declared in class <implementing class> cannot override the method of the same signature declared in interface <interface name>. The access modifier is made more restrictive."


      Why this is wrong:

      Interface "iTest" in package "tester" defines a method with the default access privileges. Therefore, this method should be callable only by classes in the same package in which "iTest" is declared, "tester".

      Implementing classes' versions of the method with the same signature should similarly provide access only to classes in the same package in which the said implementing classes are defined, regardless of whether the implementing classes are in a different package than the interface that defines the implemented method.

            tturnidgsunw Todd Turnidge (Inactive)
            bprestonsunw Brian Preston (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: