class gc

Godmar Back
Fri Feb 26 15:17:00 GMT 1999


I have a quick question about class gc in gcj's run-time.
It appears that gcj puts java_lang_Class objects in the data segment.
Class gc requires that objects keep their classes alive, but classes
can also be kept alive through direct references from static or non-static
variables.  In either case, the walk function of the containing object
must mark the class objects to which it refers.

This could be somewhat problematic for those walk functions that
follow references to class objects that are stored in ordinary objects 
or in arrays of type [Ljava/lang/Class.   Either you'll need to check
on the collector side that you don't mark anything you haven't allocated
(which seems expensive and act against the idea of precise walking/marking),
or you'll have to check on the walk function side that you don't try to
mark anything that wasn't allocated.  The latter seems error-prone and
would require a lot of special-casing.

What do you think?  Is this currently a problem in gcj at all (given that 
maybe all class objects are in the data segment and hence there may be no need
to mark them at all?)  It is definitely a problem in hybrid applications
that allow both precompiled and loaded classes.

	- Godmar

More information about the Java mailing list