Name: viR10068 Date: 02/05/2001
Javac does not follow new edition of the chapter 13 "Binary Compatibility" in JLS-2 and
violates the assertion (13.1 The Form of a Binary): "If the expression is referenced by a
simple name, then if f is a member of the current class or interface, C, then let T be C.
Otherwise, let T be the innermost lexically enclosing class of which f is a member. T is
the qualifying type of the reference."
All javacs till the JDK1.4.0beta-b50 still follow obsolete rules for member binary
references that were stated in JLS 1st ed. In the sample below reference to the
field f ( #2 in Constant Pool ) in the C.class includes name of the class S (#5)
where it is defined. But the ref should include name of the class C that is a
compile-time type of the instance a member of which the field f is.
Javac generates refs to inherited methods in the same way.
This bug affects new JCK tests :
lang/BINC/binc057/binc057.html
lang/BINC/binc058/binc058.html
See the source code for details.
The source code (ó.java) was compiled and decoded (ó.class):
-------------------------- ó.java -------------------------------
class S {
int f = 7;
int x = f;
}
class C extends S {
int y = f;
}
-------------------------- C.class -------------------------------
class C {
0xCAFEBABE;
3; // minor version
45; // version
[] { // Constant Pool
; // first element is empty
Method #5 #14; // #1
Field #5 #15; // #2
Field #4 #16; // #3
class #17; // #4
class #18; // #5
Utf8 "y"; // #6
Utf8 "I"; // #7
Utf8 "<init>"; // #8
Utf8 "()V"; // #9
Utf8 "Code"; // #10
Utf8 "LineNumberTable"; // #11
Utf8 "SourceFile"; // #12
Utf8 "ó.java"; // #13
NameAndType #8 #9; // #14
NameAndType #19 #7; // #15
NameAndType #6 #7; // #16
Utf8 "C"; // #17
Utf8 "S"; // #18
Utf8 "f"; // #19
} // Constant Pool
....
------------------------------------------------------------------
======================================================================