Adding fields to object_type_node
Bryce McKinlay
bryce@waitaki.otago.ac.nz
Thu Oct 4 15:11:00 GMT 2001
On Friday, October 5, 2001, at 06:51 AM, Dachuan Yu wrote:
> I was trying to add one more field into
> "object_type_node" and "class_type_node". It was
> only 5 lines of code. But after the change,
> HelloWorld.java would be compiled wrong such that it
> gives segment fault when the output HelloWorld
> executable is run. I was hoping that I could cheat
> by asking people who are familiar with gcj and the
> tree representation...
>> Basicly I want to add a new structure "otable" along
> with the "vtable". Starting simple, I was just
> trying to add this "otable" into "object_type_node"
> and "class_type_node". It's not used anywhere yet. I
> added this "otable" by mimicing the way "vtable" is
> added (even the type is the same), as follows,
Firstly, why do you need to change object_type_node? It should be
sufficient to just add a new field to java.lang.Class (class_type_node),
containing a pointer to the otable. The compiled code will refer to the
otable directly, of course, but the runtime would use the class pointer
to fill out the otable at initialization time.
When you add a field to object_type_node or class_type_node, you need to
mirror the change in java/lang/Object.h or java/lang/Class.h
respectively. The new field must be in exactly the same order that it is
declared in the compiler. You need to also completely rebuild libjava,
so that the change is reflected in all compiled classes.
The runtime (or compiler) might be making some assumptions somewhere
about the number of fields in Object, which could be causing the crash
you're seeing. It should work to add new fields to Class, however.
regards
Bryce.
More information about the Java
mailing list