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

Using private method from another class.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.0.2, 1.1, 1.1.1
    • hotspot
    • sparc
    • solaris_2.4, solaris_2.6



      Name: vsC45997 Date: 10/08/96


      The section "12.3.3 Resolution of Symbolic References" of The Java Language
      Specification contains the following:

      "This error may be thrown at any point in the program that uses a symbolic reference to the type, directly or indirectly:

          IllegalAccessError: A symbolic reference has been encountered that
          specifies a use or assignment of a field, or invocation of a method,
          or creation of an instance of a class, to which the code containing the
          reference does not have access because the field or method was declared
          private, protected, or default access (not public), or because the class
          was not declared public. This can occur, for example, if a field that is
          originally declared public is changed to be private after another class
          that refers to the field has been compiled (§13.4.6)."

      Verifier permits to use the private method from another class.

      > javac -d . exec00502.java
      > javac -d . exec00502a.java
      > java -verify javasoft.sqe.tests.lang.exec005.exec00502.exec00502
      failed


      --------------------------exec00502------------------------------
      package javasoft.sqe.tests.lang.exec005.exec00502;
      import java.io.PrintStream;
      public class exec00502 extends exec00502a {
        public static void main(String argv[])
        {
           System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }
        public static int run(String argv[],PrintStream out) {
          try {
            prc (6);
          }
          catch (Error e) {
            out.println ("er2 " + e);
            return 0;
          }
          out.println ("failed");
          return 2;
        }
      }
      class exec00502a {
        int a = 5;
        static int prc (int i) {
          return i;
        }
      }
      -----------------------------------------------------------------
      --------------------------exec00502a-----------------------------
      package javasoft.sqe.tests.lang.exec005.exec00502;
      public class exec00502a {
        int a = 5;
        private static int prc (int i) {
          return i;
        }
      }
      -----------------------------------------------------------------

      ======================================================================

            sliangsunw Sheng Liang (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: