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

javac incorrectly denies access to protected inner class from subclass

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.2
    • tools
    • sparc
    • solaris_2.6



      Name: skT45625 Date: 04/27/2000


      gleichtm:/home/gleichtm> /opt/bin/java -version
      java version "1.2.2"
      Solaris VM (build Solaris_JDK_1.2.2_05a, native threads, sunwjit)
      gleichtm:/home/gleichtm> uname -a
      SunOS toto.i2image.com 5.6 Generic_105181-17 sun4m sparc SUNW,SPARCstation-20


      This bug has been reported as closed and fixed against version JDK1.2fcs. See
      bug id 4158650. The bug does indeed appear to be fixed on the Windows platform.
      Unfortunately, the bug does not appear to be fixed on the SPARC platform
      running Solaris 2.6 or an IBM Pentium II box running Red Hat Linux 6.1.

      On Linux box used BlackDown compiler:
      [gleichtm@linuxdev1 /tmp]$ java -version
      java version "1.2.2"
      Classic VM (build Linux_JDK_1.2.2_RC4, native threads, sunwjit)
      [gleichtm@linuxdev1 /tmp]$ uname -a
      Linux linuxdev1.i2image.com 2.2.12-32 #1 Mon Oct 25 19:43:07 EDT 1999 i586
      unknown

      and also on Linux box used Sun's compiler:
      [gleichtm@linuxdev1 bin]$ ./java -version
      java version "1.2.2"
      Classic VM (build 1.2.2-L, green threads, nojit)
      [gleichtm@linuxdev1 share]$ uname -a
      Linux linuxdev1.i2image.com 2.2.12-32 #1 Mon Oct 25 19:43:07 EDT 1999 i586
      unknown

      This represents a show-stopper for us on these platforms. We hope that the
      working code in the Windows version is QUICKLY ported to the UNIX boxes,
      especially Solaris.

      Below is example code with the resulting failure:

      package innerClassProblem;

      import innerClassProblem2.MyClass2;

      public class MyClass1 extends MyClass2 {


        public MyClass1() {
          MyInnerClass1 theInnerClass1 = new MyInnerClass1();
          theInnerClass1.MyInnerClass2Method();
        }

        protected class MyInnerClass1 extends MyInnerClass2 {

          public void MyInnerClass2Method() {
            super.MyInnerClass2Method();
            System.out.println("Overridden inner class and overridden method: " +
                               MyInnerClass1.class);
          }
        }
        
        public static void main(String[] args) {
          MyClass1 myClass1 = new MyClass1();
          myClass1.invokedStandalone = true;
        }
        private boolean invokedStandalone = false;
      }

      ---
      package innerClassProblem2;

      import java.awt.event.WindowAdapter;

      public class MyClass2 {

        public MyClass2() {
        }

        protected class MyInnerClass2 extends WindowAdapter {

          public MyInnerClass2() {
          }

          public void MyInnerClass2Method() {
            System.out.println("Original inner class and original method: " +
                               MyInnerClass2.class);
          }
        }
      }
      ---
      [gleichtm@linuxdev1 /tmp]$ javac *.java
      MyClass1.java:16: The type innerClassProblem2.MyClass2.MyInnerClass2 to which th
      e member MyInnerClass2Method belongs is not accessible from inner class innerCla
      ssProblem.MyClass1. MyInnerClass1.
            super.MyInnerClass2Method();
                                     ^
      1 error
      [gleichtm@linuxdev1 /tmp]$

      ---

      Under Window's the app. compiles and produces:

      Original inner class and original method: class innerClassProblem2.MyClass2
      $MyInnerClass2
      Overridden inner class and overridden method: class innerClassProblem.MyClass1
      $MyInnerClass1
      (Review ID: 104203)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: