We help IT Professionals succeed at work.

JNI, Java and C Best Practices

cgray1223
cgray1223 asked
on
Hello,

I'm using SWIG to generate my JNI layer for a large set of C APIs and I was wondering what is the best practices for the below situations.  The below not only pertain to SWIG but JNI in general.  

When C functions return pointers to Structures, should the SWIG interface file (JNI logic) be heavily used or should C wrapper functions be created to return the data in pieces (i.e. a char array that contains the various data elements)?
When C Functions return void* should the C APIs be modified to return the actual data type, whether it be primitive or structure types?
I'm unsure if I want to add a mass amount of logic and create a middle layer (SWIG interface file/JNI logic). Thoughts?
Comment
Watch Question

Awarded 2011
Awarded 2011
Commented:

don't know if you lloked at this article:
http://www.ibm.com/developerworks/java/library/j-jni/

cannot say if it answerd your specific questions, but seems to havbe a lot of wisdom about JNI