-
Bug
-
Resolution: Fixed
-
P4
-
1.1
-
1.2
-
sparc
-
solaris_2.4
-
Not verified
Name: akC45999 Date: 07/22/97
The section "4.4.2 CONSTANT_Fieldref, CONSTANT_Methodref,
CONSTANT_InterfaceMethodref" of JVM spec says about class_index
item:
"The class_index item of a CONSTANT_Fieldref_info ...
structure must be a class type, not an interface type".
But sun's JDK permits a CONSTANT_Fieldref_info structure
to refer to an interface type. See example:
/*-------------------------------- fieldref.java */
interface fieldref_i {
String s = new String("xxx");
}
public class fieldref implements fieldref_i {
public static void main(String argv[]) {
fieldref_i obj=new fieldref();
System.out.println(obj.s);
}
}
/*----------------------------- */
Disassembled class contains instruction:
const #2 = class #29; // fieldref_i
const #10 = Field #2.#14; // fieldref_i.s:"Ljava/lang/String;"
const #14 = NameAndType #36:#24; // s:"Ljava/lang/String;"
const #24 = Asciz "Ljava/lang/String;";
const #29 = Asciz "fieldref_i";
const #36 = Asciz "s";
getstatic #10; // Field fieldref_i.s:"Ljava/lang/String;";
/*-------------------------------*/
I cannot see other way to compile the fieldref.java source.
So I believe that the error is in the JVM spec rather than in the JVM
implementation.
See also bug 4054281 which is closed because the applied test was incorrect.
======================================================================