Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to instantiate a java object (using JNI)?(n'more)

843829Apr 22 2003 — edited Feb 3 2004
hey bschauwe, thanks for your last post, you were guessing but your 4th guess was right on the money of how id like to do it.

"4. An alternative way to return data to java from C is to instantiate a java object (using JNI), then use JNI to call that object's setters, then return the object at the end of the C routine."

I know now how to get the object's setters, I am just unsure how to instantiate a java object from the native C code using JNI. Also you said to returnt he object at the end of the c routine, that is just a good ol' return statement right? no other functions to release memory or anything are needed? So basically it would be something like:
JNIEXPORT jobject retObj JNICALL Java_AbfaRegion_getJSourceData
  (JNIEnv *env, jobject thisObj)
{
        //instantiate the java object on retObj????
        //call setters with values from the c structures...
        //return retObj??? no other memory releasing needed?

}
Thanks again for all your help,
Shane
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2004
Added on Apr 22 2003
7 comments
2,220 views