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

New compiler incorrectly allows inheritance of private fields

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0
    • tools
    • generic
    • generic

      The following well-formed program is rejected by javac-ea:

      package othello;

      public class H extends I
      {
          public static void main (final String[] args)
          {
              q.f();
          }
      }

      class I
      {
          void f () { System.out.println("I.f()"); }
          private static I q;
      }

      class q
      {
          static void f () { System.out.println("q.f()"); }
      }

      It complains that "q" is private, i.e. it is resolving the simple name "q"
      in H.main() to the private static field of H's superclass, rather than to
      the package-scope type q, even though private members are not inherited.

      [from Roly]

      william.maddox@Eng 1999-06-23

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: