This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: confusion when CLASSPATH includes compiled class
- From: Tom Tromey <tromey at redhat dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: java at gcc dot gnu dot org
- Date: 23 Mar 2005 13:00:03 -0700
- Subject: Re: confusion when CLASSPATH includes compiled class
- References: <424081E2.7060707@bothner.com>
- Reply-to: tromey at redhat dot com
>>>>> "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