This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Adding fields to object_type_node
>>>>> "Dachuan" == Dachuan Yu <dachuan.yu@yale.edu> writes:
Dachuan> Sorry that I have to come back to the old question of last
Dachuan> week. Could you please give an example how the compiled code
Dachuan> refers to the fields in java.lang.Class? I think I'm confused
Dachuan> about the relationship between the fields in java.lang.Class
Dachuan> and the fields in class_type_node.
class_type_node is jc1's internal representation of java.lang.Class.
jc1 needs this internal representation because it internally builds
Class objects which are then written to the object file.
Look at the PUSH_FIELD code in decl.c:init_decl_processing() and the
Class fields in libjava/java/lang/Class.h at the same time. You'll
see a correspondence: each PUSH_FIELD in init_decl_processing()
corresponds to a field in Class.h; they come in the same order and
have the same types.
So, if you want to add a field to the Class class, you must add it in
decl.c, class.c (look for PUSH_FIELD_VALUE -- this is where a new
Class object is created), and Class.h. You might need to initialize
the field elsewhere in the runtime too (for instance when a new
interpreted class or new array class is built).
Note that fields in Class are *not* in Class.java. I don't know the
reason why, but if you put the fields there then gcj gets very
confused.
A similar situation holds for Object: fields aren't in Object.java,
but they are in decl.c, class.c, and Object.h.
Methods are different -- they must appear in the .java files. They
have to occur in the same order in a .java file as in the
corresponding .h file. Object.h and Class.h are special in that they
are hand-maintained (other headers are generated by gcjh).
Does this answer your question?
Tom