Posted By:
Anil_Datt
Posted On:
Tuesday, October 23, 2001 01:51 PM
You can keep a long variable (to address 64 bit needs) in you java program.For example call it as
long cObjectID;
in your C/C++ code you can have funtion like the following
void setCObjectId
(JNIEnv *env, jobject thisObject, jlong lCObjectId){
jclass classzz = env->GetObjectClass(thisObject);
jfieldID fid =env->GetFieldID(classzz,"cObjectID","J");
env->SetLongField(thisObject,fid,lCObjectId);
}
which sets the pointer associated with you struct pointer which is passed through "lCObjectId".
You can have the additional method
jlong getCObjectId
(JNIEnv *env, jobject thisObject){
jclass classzz = env->GetObjectClass(thisObject);
jfieldID fid =env->GetFieldID (classzz,"cObjectID","J");
jlong id = env->GetLongField(thisObject,fid);
return id;
}
to get the Pointer.
Similar to to this you can have a set and get in you java class to reference the pointer.