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

access to non-public class are permitted from another package

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1beta3
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Not verified

      Description



      Name: vgC55224 Date: 11/26/96


      The section "7.5.1 Single-Type-Import Declaration" of The Java Language
      Specification contains the following:

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


      Java compiler (JDK1.1) produces warning message instead of error message.

      > jac11 -d . pkgs02003a.java
      > jac11 -d . pkgs02003.java
      javasoft.sqe.tests.lang.pkgs020.pkgs02003.pkgs02003a.pkgs02003b. Only public classes and interfaces in other packages can be accessed.
           pkgs02003b cl = null;
           ^
      1 warning
      > ja11 javasoft.sqe.tests.lang.pkgs020.pkgs02003.pkgs02003
      null

      --------------------------pkgs02003a.java------------------------------
      package javasoft.sqe.tests.lang.pkgs020.pkgs02003.pkgs02003a;
      import java.io.PrintStream;
      public class pkgs02003a {
         static public int val = 6;
      }
      class pkgs02003b {
         static public int val = 7;
      }
      -----------------------------------------------------------------
      --------------------------pkgs02003.java------------------------------
      package javasoft.sqe.tests.lang.pkgs020.pkgs02003;
      import java.io.PrintStream;
      import javasoft.sqe.tests.lang.pkgs020.pkgs02003.pkgs02003a.pkgs02003b;
      public class pkgs02003 {
        public static void main(String argv[]) {
           System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
        }
        public static int run(String argv[],PrintStream out) {
           pkgs02003b cl = null;
           out.println (cl);
           return 0;
        }
      }
      -----------------------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jrose John Rose
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: