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
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
- relates to
-
JDK-4273927 -Xcomp causes VM crash for the interface hierarchy test
- Resolved
-
JDK-4112313 Legal program, compiled as prescribed by the JLS, gets IllegalAccessError
- Resolved
-
JDK-4271096 Field resolution does not look up the interface hierarchy
- Closed