javac allows packages to call public static methods on package-private classes

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 1.1
    • Affects Version/s: 1.1
    • Component/s: tools
    • None
    • 1.1beta3
    • x86
    • windows_nt
    • Not verified


      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

            Assignee:
            John Rose
            Reporter:
            Graham Hamilton (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: