-
Bug
-
Resolution: Not an Issue
-
P2
-
repo-valhalla
Access checks are not performed for inline typed fields.
Example:
public class OtherClass {
static primitive class SecretClass {
byte b = 0;
}
}
public primitive class AccessCheckTest {
short s = 0;
OtherClass.SecretClass sc = new OtherClass.SecretClass();
void print() {
System.out.println("s="+s+" sc.b="+sc.b);
}
public static void main(String[] args) {
AccessCheckTest[] array = new AccessCheckTest[10];
array[0].print();
}
}
This code runs normally and prints the value of the fields.
If the declaration of OtherClass.SecretClass is modified to make it private, and only OtherClass is recompiled, the main method of AccessCheckTest still prints the value of the fields without any access error being reported.
Example:
public class OtherClass {
static primitive class SecretClass {
byte b = 0;
}
}
public primitive class AccessCheckTest {
short s = 0;
OtherClass.SecretClass sc = new OtherClass.SecretClass();
void print() {
System.out.println("s="+s+" sc.b="+sc.b);
}
public static void main(String[] args) {
AccessCheckTest[] array = new AccessCheckTest[10];
array[0].print();
}
}
This code runs normally and prints the value of the fields.
If the declaration of OtherClass.SecretClass is modified to make it private, and only OtherClass is recompiled, the main method of AccessCheckTest still prints the value of the fields without any access error being reported.