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

Field resolution does not look up the interface hierarchy

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.3.0
    • 1.2.0, 1.3.0
    • hotspot
    • None
    • kestrel
    • generic
    • generic

      Field resolution as implemented does not conform to the JVMS (5.4.3.2).
      According to the spec, when resolving a symbolic reference to a field in an
      instruction, the VM first looks in the class specified by the symbolic
      reference; if the field is not found, the VM looks first in the direct
      superinterfaces, and then in the superclass.

      Consider the following code:

      package p;
      interface Parent {
       static public int fld[] = {5,10};
      }

      package p;
      public interface Child extends Parent {}


      import p.Child;
      class B implements Child {
         static public void main(String [] args) {
             B b = new B();
            System.out.println(b.fld[0]);
            System.out.println(Child.fld[0]);
         }
      }


      This program should work, but fails with a NoSuchFieldError. The references
      to fld are compiled into symbolic references to B.fld and Child.fld. The
      lookup algorithm given in the JVMS should be able to find fld in the
      Parent superinterface.

      This problem appears in both 1.3 and 1.2.

      gilad.bracha@eng 1999-07-26

            rgriesemsunw Robert Griesemer (Inactive)
            gbrachasunw Gilad Bracha (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: