Finding the declaring class of a _Jv_Field

Mark Wielaard mark@klomp.org
Sun Oct 29 12:51:00 GMT 2000


Hi,
The gij interpreter doesn't check if a field is final so I thought I
would fix that. I added a flag to _Jv_ResolvePoolEntry to indicate
that the field to be resolved was going to be changed. So I could
just add a little extra check:
 ((!change_field || ((field->flags & Modifier::FINAL) == 0))
This does work, but only when you try to put something in a final
field (from another class) when it is not yet resolved. Duh...
The correct fix is to check in interpret.cc after putfield or putstatic
have already called _Jv_ResolvePoolEntry on the field. And then check
if the defining_class of the instruction is the same as the declaring_class
of the field you are about to modify.
But after calling _Jv_ResolvePoolEntry I only have a _Jv_Field and I
cannot figure out how to get the declaring class for it. How is that done?
Thanks,
Mark
P.S. I saw that Alexandre Petit-Bianco was fixing gcj to honor final fields
but this is about the interpreter. Without his fixes you can easily generate
byte code with gcj that tries to set final fields in other classes :)


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /