Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4022377

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.1
    • 1.1
    • 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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: