[kaffe] libraries/clib/native/Field.c
Jukka Santala
jsantala@tml.hut.fi
Tue, 7 May 2002 15:13:11 +0300 (EEST)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---559023410-1254324197-1020773591=:809
Content-Type: TEXT/PLAIN; charset=US-ASCII
static
void*
//getFieldAddress(Hjava_lang_reflect_Field* this, struct
Hjava_lang_Object* obj)
getFieldAddress(struct Hjava_lang_Object* obj, Hjava_lang_reflect_Field*
this)
{
I could not yet determine why exactly (not being able to run with debugger
does that to you), but getFieldAddress() in Field.c for some reason gets
the incoming parameters to it reversed. Since it's called by
jint
Java_java_lang_reflect_Field_getInt0(struct Hjava_lang_reflect_Field *
this, struct Hjava_lang_Object* obj)
{
return (*(jint*)getFieldAddress(this, obj));
}
I don't immediately see why this should happen, but it does seem to
happen. Swapping the parameters aroudn as above seems to solve the
problem, but it's perhaps a good diea to figure out what's going on. It
seems the swapping-around only works for static fields; could it be the VM
is trying to pass the JNI environment or similiar first in the stack
bumping the rest of the addresses?
Attached a regression-test with some of the most basic Field tricks. The
variety of alternatives with different combinations to test is ofcourse
infinite, but I believe these are the ones Kaffe right now has most
potential trouble with. The expected results are from JDK 1.4, and I
notice Kaffe doesn't do as detailed exception reporting, so either the
expected outputs or exception reporting needs to be adjusted. Completely
untested remain inheritance, interfaces and reflection access control.
-Jukka Santala
---559023410-1254324197-1020773591=:809
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="GetField.java"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SOL.4.10.10205071513110.809@morphine.tml.hut.fi>
Content-Description:
Content-Disposition: attachment; filename="GetField.java"
aW1wb3J0IGphdmEubGFuZy5yZWZsZWN0LkZpZWxkOw0KDQpjbGFzcyBTb21l
RmllbGRzIHsNCglwdWJsaWMgaW50IFNPTUUgPSAxMDsNCglwcm90ZWN0ZWQg
aW50IFBTT01FID0gMjA7DQp9DQoNCmNsYXNzIEdld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