confusion when CLASSPATH includes compiled class
Tom Tromey
tromey@redhat.com
Wed Mar 23 20:03:00 GMT 2005
>>>>> "Per" == Per Bothner <per@bothner.com> writes:
Per> If I run a gcj-compiled application that has class Foo.java/Foo.class
Per> compiled and linked into the executation, with a CLASSPATH that
Per> includes Foo.class then things get really confused.
Per> A Class.forName("Foo") will load the class in the CLASSPATH.
When I try this with my current cvs trunk build, it works fine.
I would expect to see the compiled-in class always be used, because
ordinary class loaders delegate to their parent before doing any local
processing, and the root of the tree will look at compiled-in classes.
Per> On the other hand other native code will reference the native-class.
Per> I end up with a weird GC failure: the GC tries to mark a static field:
Per> jobject val = *(jobject*) field->u.addr;
Per> Unfortunately, the field->u.addr is null, even though field->isResolved()
Per> is true. I fairly sure this is the field for the class loaded using the
Per> CLASSPATH. I'm not sure when the field->u.addr is supposed to be set -
Per> perhaps during class initialization?
This is definitely a bug.
Fields are allocated by ensure_fields_laid_out(). This only happens
for interpreted classes, since compiled classes have their fields
created by the compiler.
I made a change to field lookup a few weeks ago that seems to have
broken this code. I think we can work around this with a check in
boehm.cc, but I need to investigate some more.
Tom
More information about the Java
mailing list