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

Protected inner classes are wrongly rejected in 'extends' clauses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.0
    • 1.1.4, 1.2.0
    • tools
    • 1.2beta2
    • unknown, x86, sparc
    • solaris_2.5, solaris_2.5.1, windows_nt
    • Not verified

      Protected inner classes are available at all points in the immediate body
      of any subclass of the protecting (i.e., enclosing) class. However, the
      compiler rejects an attempted reference to a protected inherited class
      if the reference occurs as a supertype of a further inner class.

      (Note: This bug is masked when the two classes are in the same package,
      because the compiler allows the reference on different grounds.)

      Here is an example:
      ==> B.java <==
      package b;
      public class B {
      protected class M { }
      }

      ==> C.java <==
      package c;
      import b.B;
      class C extends B {
      M m; // OK
      class N extends M { } // BAD
      }

      The output is:

      C.java:5: Can't access inner class b.B. M. Only public classes and interfaces in other packages can be accessed.
          class N extends M { } // BAD
                          ^
      1 error


      --------
      This problem is seen again in JDK1.2FCS-B build from /usr/local/java/jdk1.2fcs.
      These files compiled fine with JDK1.2beta4-K build.
      Compiling B.java and C.java throws the following error.

      C.java:5: The type b.B.M to which the member <init> belongs is not accessible from inner class c.C. N.
                  class N extends M { } // BAD
                        ^
      1 error

      Note : This scenario is used in one of the Accessibility tools used for testing JDK1.2 build. Hence the tools are not testable with JDK1.2FCS-B build. They compiled fine with JDK1.2beta4-K build.

      mukund.madhugiri@eng 1998-07-20

            wmaddoxsunw William Maddox (Inactive)
            jrose John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: