Another reflection bug; compatibility results
Godmar Back
gback at cs.utah.edu
Thu Jun 15 08:44:22 PDT 2000
>
>
> Godmar Back wrote:
> >
> > Have you tried calling 1.2's Class.forName(,false,) and then
> > using getField().getValue() on a final static field?
> > Does doing this invoke <clinit>?
>
> I need to be able to run on 1.1...
In 1.1 w/ reflection, you're obviously out of luck since
Class.forName will call <clinit>
>
> This is a fairly specific situation that is probably extremely rare. My
> program attempts to print out a description of the public API of a class
> in a machine-readable format that can then be compared to other such
> descriptions. Compile-time constants are part of the public API, other
> fields' values (even public static final ones) are not. Reflection
> doesn't let me distinguish between the two cases.
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.
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.
- Godmar
More information about the kaffe
mailing list