This was originally reported by IBM.
If you have a package private class that declares public static methods,
then the compiler allows other packages to call these public static methods,
even though they are in an inaccessible class. This appears to violate the
language spec.
Here are two test files that demonstrate the bug.
First file is a/A.java
package a;
class A {
// This is a public method within a package-private class.
public static void doA() { }
}
Second file is b/B.java
package b;
class B {
void doB() {
// call a public static method on an inaccessable class.
a.A.doA();
}
}
KGH 12/16/96
- relates to
-
JDK-4009152 Using public field of non-public class from another package is permitted.
-
- Closed
-