Another reflection bug; compatibility results

Stuart Ballard sballard at netreach.net
Wed Jun 14 09:45:18 PDT 2000


"Edouard G. Parmelan" wrote:
> 
> For now, Japize does not extrate final values (or I missing something)
> so with method Class.forName(String name, boolean initialize, ClassLoader
> loader) [yes it's 1.2] <clinit> is never called, so no native code :-)

Actually, Japize does extract all field values that are public, static,
final, and of a primitive type or String. The intent is to catch
primitive constants, since the values have to be the same for
compatibility. However, there are two possible errors here; one is that
being public, static and final is not actually sufficient to be a
primitive constant; the field also has to be initialized to a
compile-time constant value. I'm hoping that it's rare for classes to
have public static final primitive-typed variables that are not compile
time constants. The other possible error is that null is a compile-time
constant, even for non-String objects - Japize would not catch this.
This also seems unlikely - why would you declare a public variable if
it's going to be a compile-time constant null? java.lang.reflect.Field
needs an isPrimitiveConstant() method...

However, I think that asking for the value of a field, even a public
static final one, is enough to cause <clinit> to get called... right? :(

> > I do have a slight twinge of regret that as things stand now I can't
> > ever produce a jdk10.japi...
> 
> I will try to write a small ClassLoader to use with Kaffe to generate
> jdk10.japi.

That would be awesome :) I was thinking about perl hacks on the output
of javap... ;)

Stuart.


More information about the kaffe mailing list