Another reflection bug; compatibility results
Stuart Ballard
kaffe@rufus.w3.org
Thu, 15 Jun 2000 14:09:45 -0400
Godmar Back wrote:
>
> In 1.1 w/ reflection, you're obviously out of luck since
> Class.forName will call <clinit>
Blah. I guess I should explore options that look at the bytecode, rather
than reflection, then... (the most important reason I need to run on 1.1
is to get reliable docs *for* 1.1)
> Whether or not something is a compile-time constant or not is of no
> relevance IMO.
>
> For instance, a class may define a public static final int K = 5;
> A compiler is free to inline the 5 where it sees K, but not required to do so.
> The compiler may as well produce a getfield instruction.
Unfortunately it does make a difference. The only reason primitive
constants are part of the public API is because they *can* be inlined
(code compiled against the JDK could break on Kaffe if the compiler had
inlined the value of something that kaffe defined differently; it
doesn't matter that the compiler is free to *not* do this - just the
possibility that it can is enough). If the value is not a primitive
constant, it couldn't be inlined, so a getfield call would *have* to be
issued... and the right value would be "got" on both VMs even if they
were different.
> To my knowledge, even though static final constants are part of the
> public API, their values are not given by Sun and so they have to be
> determined experimentally.
Exactly why I want to report them as part of Japize... to make it
possible to automate testing that Kaffe (and GNU Classpath) has gotten
all the values right.
Stuart.