JNI Programming Tips??
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jaitirth_Shirole
Posted On:   Wednesday, June 23, 2004 01:02 AM

Hi, We are using JNI in our GUI code. The Java code has a class 'A' having native method declarations and a value object(VO) Class 'B'. The values for the fields of this VO are sent by a C++ function to class A as a result of native call from Java. Class A then creates Class B objects and populates them with the data from C++ function. The objects of B are going to be an array's elements. I have two options to achieve this:- 1)Make a native call from Class A to the C++ function. Before this call returns back to Java,let C++ function call back the Java method.After the call backs are done, return the original call to Java. The callback method is in class A, which is called by    More>>

Hi,

We are using JNI in our GUI code.
The Java code has a class 'A' having native method declarations and a value object(VO) Class 'B'. The values for the fields of this VO are sent by a C++ function to class A as a result of native call from Java. Class A then creates Class B objects and populates them with the data from C++ function.
The objects of B are going to be an array's elements.

I have two options to achieve this:-
1)Make a native call from Class A to the C++ function.
Before this call returns back to Java,let C++ function
call back the Java method.After the call backs are done,
return the original call to Java.

The callback method is in class A, which is called by
C++ JNI function for every Class B's object creation and
population.

The scenario would be to have a for loop in C++
function, thru which Java's method is called back for
every iteration.

2)Rather than calling back A's method before the original
native call (from java to C++) returns, let the C++
function create objects of Class B, populate them in a
java.util.Vector object and return to java code.
No need to have callbacks from C++ function to Java.

I would like to get a feedback from JNI experts, which
one from the above two would be perform better.
By performance I mean no crashes to the application.

Thanks,

   <<Less
About | Sitemap | Contact