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

Field resolution does not look up the interface hierarchy

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.2.0, 1.3.0
    • Fix Version/s: 1.3.0
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      kestrel
    • CPU:
      generic
    • OS:
      generic

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: