On 2 Feb 2006 10:32:31 -0800, stixwix wrote:
> With regard to the clip above, do i need to do this if I am passing
> an (instantiated) object into the c code from the java code?
Yes, it's perfectly reasonable to use the enclosing object ("this")
when you create instances of its inner class.
> /* get the address field from MyClass */
> jfieldID fidStr = (*env)->GetFieldID(env, fid, "address",
> "Ljava/lang/String;");
>
> It crashes when I introduce the last line.
You're attempting to find the fieldID by looking it up in another
fieldID, but you should be looking in a class instead.
Start with the class HelloNative$MyClass, and from there you can look
up its fields:
jclass my_cls = (*env)->FindClass(env,"HelloNative$MyClass");
jfieldID addr_fid = (*env)->GetFieldID(env,my_cls,"address",
"Ljava/lang/String;");
Now to actually get or change the *value* associated with this field,
you need an *object* of that type (i.e. one that holds the field you
just looked up), and you choose one of the Get/Set<type>Field()
functions based on the type of the field itself (i.e. one of the
primitive types, or Object for all others).
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
|