I read on on IBM that
To access Java objects\' fields and invoke their methods, native code must make calls to FindClass(), GetFieldID(), GetMethod
You can have some utility structures like this:
typedef struct MYVARIANT_FID_CACHE {
int cached;
jclass clazz;
jfieldID pAddress;
} MYVARIANT_FID_CACHE;
MYVARIANT_FID_CACHE VARIANTFc;
void cacheMYVARIANTFields(JNIEnv *env, jobject lpObject)
{
if (VARIANTFc.cached) return;
VARIANTFc.clazz = env->GetObjectClass(lpObject);
VARIANTFc.pAddress = env->GetFieldID(VARIANTFc.clazz, "pAddress", "I");
VARIANTFc.cached = 1;
}
VARIANT *getMYVARIANTFields(JNIEnv *env, jobject lpObject, VARIANT *lpStruct)
{
if (!VARIANTFc.cached) cacheVARIANT2Fields(env, lpObject);
lpStruct = (VARIANT*)(env->GetIntField(lpObject, VARIANTFc.pAddress));
return lpStruct;
}
This is taken from my question: https://stackoverflow.com/questions/10617714/how-to-extend-swt-com-support
For some good examples look at the os_structs.c
it is bundled with eclipse SWT implementation.
Note: The above code is just an example and could be adapted for different OS. Also it just shows "how to access java fields"; for methods you could follow the same approach.