-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.2.0
-
generic
-
solaris_2.5.1
Licensee is questioning the JLS section 8.2.1.4, "Accessing Members of
Inaccessible Classes". Licensee believes he is incorrectly getting error :
java.lang.IllegalAccessError: try to access class
morePoints/Point3d from class points/Point
at points.Point.main(Point.java:13)
when trying to run code:
// file: Point.java
package points;
import morePoints.Point4d;
public class Point {
public int x, y;
public void move (int dx, int dy) {
x += dx; y += dy;
}
// I added the method main to what appears in the JLS.
public static void main (String [] argv) {
Point4d o_4d = new Point4d ();
// This line produces the same erroneous illegal access
// error. The JLS says that "the field z, which, being
// public, could then be accessed by code in packages
// other than morePoints, through variables and expressions
// of the public type Point4d.
o_4d.z = 10;
}
}
// file: Point4d.java
package morePoints;
class Point3d extends points.Point {
public int z;
public void move (int dx, int dy, int dz) {
super.move (dx, dy); z += dz;
}
}
public class Point4d extends morePoints.Point3d {
public int w;
public void move (int dx, int dy, int dz, int dw) {
super.move (dx, dy, dz); w += dw;
}
}
His sample code used to work using JDK1.2Beta2 and now doesn't work
using JDK1.2Beta3.
Inaccessible Classes". Licensee believes he is incorrectly getting error :
java.lang.IllegalAccessError: try to access class
morePoints/Point3d from class points/Point
at points.Point.main(Point.java:13)
when trying to run code:
// file: Point.java
package points;
import morePoints.Point4d;
public class Point {
public int x, y;
public void move (int dx, int dy) {
x += dx; y += dy;
}
// I added the method main to what appears in the JLS.
public static void main (String [] argv) {
Point4d o_4d = new Point4d ();
// This line produces the same erroneous illegal access
// error. The JLS says that "the field z, which, being
// public, could then be accessed by code in packages
// other than morePoints, through variables and expressions
// of the public type Point4d.
o_4d.z = 10;
}
}
// file: Point4d.java
package morePoints;
class Point3d extends points.Point {
public int z;
public void move (int dx, int dy, int dz) {
super.move (dx, dy); z += dz;
}
}
public class Point4d extends morePoints.Point3d {
public int w;
public void move (int dx, int dy, int dz, int dw) {
super.move (dx, dy, dz); w += dw;
}
}
His sample code used to work using JDK1.2Beta2 and now doesn't work
using JDK1.2Beta3.