Name: ngC57085 Date: 03/02/98
Java compiler jdk1.1.6 permits using public member of non-public class
from another package.
Next two files are compiled without error message.
------------------- name05701 -----------------------
package javasoft.sqe.tests.lang.name057.name05701;
import java.io.PrintStream;
import javasoft.sqe.tests.lang.name057.name05701.name05701a.name05701c;
public class name05701 {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
int a;
boolean notpass = false;
name05701c c = new name05701c (4);
if ( c.n != 4 )
notpass = true;
try {
out.println (c.d.n);
notpass = true;
}
catch (Error ee) {
out.println (ee);
}
if ( notpass ) {
out.println("failed");
return 2/*STATUS_FAILED*/;
}
return 0/*STATUS_PASSED*/;
}
}
-----------------------------------------------------
------------------- name05701c ----------------------
package javasoft.sqe.tests.lang.name057.name05701.name05701a;
public class name05701c {
public name05701c (int c) {
n = c;
d = new name05701d (n+1);
}
public int n;
public name05701d d;
}
class name05701d {
name05701d (int c) {n = c;}
public int n;
}
-----------------------------------------------------
> java -version
java version "1.1.6"
> javac -d . name05701c.java name05701.java
> java -verify javasoft.sqe.tests.lang.name057.name05701.name05701
5
failed
>
jdk1.2beta3 compiles this test with correct error message.
======================================================================
- duplicates
-
JDK-4094658 Qualified access defeats access control.
- Closed