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

comb rule and super

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 8
    • specification
    • None
    • unknown
    • generic

      The following program doesn't compile:

      The behavior is very counter-intuitive, but the compiler is behaving correctly - the underlying problem can be understood by looking at this simpler program (w/o enums):

      class A {
         private int a = 1;

         static class B extends A {
            void test() { Object o = a; }
         }
      }

      However the following does:

      class A {
         private int a = 1;

         static class B extends A {
            void test() { Object o = super.a; }
         }
      }

      This is counter-intuitive: if A.a can be referenced through super, why is A.a discarder during field resolution (I guess on the basis that 'a' is not a member of B) ?

            abuckley Alex Buckley
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: