-
Bug
-
Resolution: Fixed
-
P3
-
1.0.2, 1.1.4, 1.1.6, 1.2.0
-
1.2beta3
-
generic, sparc
-
generic, solaris_2.4, solaris_2.5
-
Not verified
allan.jacobs@Eng 1997-10-15
The set and use of p1.p2.privatei in CMain should not be allowed because
p1.p2 has non-public class type P2.
algol% cat CMain.java
import pack1.P1;
public class CMain {
public static void main( String[] argv ) {
P1 p1 = new P1();
p1.p2.privatei = 3;
System.out.println (p1.p2.privatei);
}
}
algol% cat P1.java
package pack1;
public class P1 {
public P2 p2 = new P2();
}
algol% cat P2.java
package pack1;
class P2 {
public int privatei=0;
}
algol% setenv CLASSPATH .
algol% javac -d . P1.java P2.java
algol% javac -d . CMain.java
algol% java CMain
3
The set and use of p1.p2.privatei in CMain should not be allowed because
p1.p2 has non-public class type P2.
algol% cat CMain.java
import pack1.P1;
public class CMain {
public static void main( String[] argv ) {
P1 p1 = new P1();
p1.p2.privatei = 3;
System.out.println (p1.p2.privatei);
}
}
algol% cat P1.java
package pack1;
public class P1 {
public P2 p2 = new P2();
}
algol% cat P2.java
package pack1;
class P2 {
public int privatei=0;
}
algol% setenv CLASSPATH .
algol% javac -d . P1.java P2.java
algol% javac -d . CMain.java
algol% java CMain
3
- duplicates
-
JDK-4009154 Using public field of non-public interface from another package is permitted.
- Closed
-
JDK-4116465 access to public member of non-public class from another package
- Closed
- relates to
-
JDK-4089583 Is inaccessibility a compile-time error?
- Closed