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

compiler and runtime both permit acces to non=public classes from other packages

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.1
    • 1.0.2
    • tools
    • None
    • 1.1
    • sparc
    • solaris_2.4
    • Verified

      If the named type is not in the current package then it must be in an accessible package and declared public, or a compile-time error occurs.

      The error does not occurr.

      ============================= file pkgs040b.java
      package javasoft.sqe.tests.java_spec.pkgs040a;

      import java.io.PrintStream;

      class pkgs040b {
         static public int val = 7;
      }

      ============================= file pkgs040.java
      package javasoft.sqe.tests.java_spec.pkgs040;

      import java.io.PrintStream;
      import javasoft.sqe.tests.java_spec.pkgs040a.pkgs040b;

      public class pkgs040 {
        public static void main(String argv[]) {
           System.exit(run(argv,System.out));
        }
        public static int run(String argv[],PrintStream out) {
           if ( pkgs040b.val != 7) {
              out.println ( "not pass" );
              return 2;
           }
           return 0;
        }
      }
      =============================
      compile both and run pkgs040

            dstoutamsunw David Stoutamire (Inactive)
            rfqsunw Rfq Rfq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: