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

Qualified access defeats access control.

XMLWordPrintable

    • 1.2beta3
    • generic, sparc
    • generic, solaris_2.4, solaris_2.5
    • Not verified

      allan.jacobs@Eng 1997-10-15

      The set and use of p1.p2.privatei in CMain should not be allowed because
      p1.p2 has non-public class type P2.

      algol% cat CMain.java
      import pack1.P1;

      public class CMain {
      public static void main( String[] argv ) {
      P1 p1 = new P1();
      p1.p2.privatei = 3;
      System.out.println (p1.p2.privatei);
      }
      }
      algol% cat P1.java

      package pack1;

      public class P1 {
              public P2 p2 = new P2();
      }
      algol% cat P2.java

      package pack1;

      class P2 {
              public int privatei=0;
      }
      algol% setenv CLASSPATH .
      algol% javac -d . P1.java P2.java
      algol% javac -d . CMain.java
      algol% java CMain
      3

            wmaddoxsunw William Maddox (Inactive)
            ajacobssunw Allan Jacobs (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: