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

no runtime check of accessibility of an invoked method

XMLWordPrintable

    • sparc
    • solaris_2.4



      Name: swC45995 Date: 12/10/96


      The following assertion do not holds:

      Let C be the class containing the method invocation, and let T be the class or interface that contained the method being invoked, and m be the name of the method, as determined at compile time. ...

      The virtual machine must also insure, during linkage, that the type T and
      the method m are accessible. ...

      If either T or m is not accessible, then an IllegalAccessError occurs
      (#15.11.4.3 Check Accessibility of Type and Method)

      Thus, compilation of the source file:

      public class test
      {
      public static void main(String argv[])
      {
      int res;

      try {
      res = auxiliary.cipher();
      } catch (IllegalAccessError e) {
      System.out.println("pass");
      }
      System.out.println("fail");
      }
      }

      class auxiliary
      {
      public static int cipher()
      {
      return 777;
      }
      }

      followed by compilation of the modified version of the latter class:

      class auxiliary
      {
      private static int cipher()
      {
      return 777;
      }
      }

      and subsequent execution of the test produces such output:

      novo40% javac test.java
      novo40% javac auxiliary.java
      novo40% java test
      fail


      instead of expected:

      novo40% javac test.java
      novo40% javac auxiliary.java
      novo40% java test
      pass
      ======================================================================

            pbk Peter Kessler
            wensunw Wen Wen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: