-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.4, 1.1.5, 1.2.0
-
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();
}
}
- duplicates
-
JDK-4116802 Can a nested class access protected fields inherited by an enclosing class?
- Closed