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

Protected superclass members are not accessible to enclosed inner classes.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.4, 1.1.5, 1.2.0
    • tools
    • generic, sparc
    • generic, solaris_2.5.1, solaris_2.6


      allan.jacobs@Eng 1997-10-27

      Public class S is a superclass of class C. C is the enclosing class
      for an inner class I. Protected fields of S are not accessible in
      source code belonging to the inner class I.

      algol% uname -a
      SunOS algol 5.6 Generic sun4u sparc SUNW,Ultra-1
      algol% setenv CLASSPATH .
      algol% java -fullversion
      java full version "1.1.4n:1997.10.16"
      algol% javac -d . sX.java
      algol% javac -d . X.java
      X.java:6: Variable sXf in class sXpack.sX not accessible from inner class X. Y.
          void test() { System.out.println( sXf ); }
                                            ^
      1 error
      algol% cat sX.java

      package sXpack;

      public class sX {
              protected int sXf = 1;
      }
      algol% cat X.java

      import sXpack.sX;

      class X extends sX {
        class Y {
          void test() { System.out.println( sXf ); }
        }
        Y oy = new Y();
        public static void main( String[] argv ) {
          X ox = new X();
          ox.oy.test();
        }
      }

            wmaddoxsunw William Maddox (Inactive)
            ajacobssunw Allan Jacobs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: