V
Vikas
Hi
I want to create a struct in Java that when passed to a native/JNI C
function gets converted to a bunch of jMethodIDs.
For example, in my C code I need my structure to be like this:
struct java_callbacks {
jMethodID callback1;
jMethodID callback2;
jMethodID callback3;
};
But I want to create an object of this type in my Java class. For
example,
public class my_java_class
{
private JavaCallbacks callback_struct;
<functions>;
}
Where JavaCallbacks is the equivalent class/struct of the C struct
java_callbacks.
The reason I have to do this, is that I want the callback_struct to be
destroyed/garbage collected with the Java Class object and not have to
do it manually in the Native interface.
Could anyone enlighten me as to how I could do this easily ?
In C#, I was able to do it fairly easily by defining "public delegate"
functions and then making them part of a "struct" in C# and making an
object of that struct in the C# class. Then I could directly access
the members of the struct in C.
But I am not a Java programmer as such, and am having difficulty in
getting it to work in this way.
Thanks and regards,
Vikas
I want to create a struct in Java that when passed to a native/JNI C
function gets converted to a bunch of jMethodIDs.
For example, in my C code I need my structure to be like this:
struct java_callbacks {
jMethodID callback1;
jMethodID callback2;
jMethodID callback3;
};
But I want to create an object of this type in my Java class. For
example,
public class my_java_class
{
private JavaCallbacks callback_struct;
<functions>;
}
Where JavaCallbacks is the equivalent class/struct of the C struct
java_callbacks.
The reason I have to do this, is that I want the callback_struct to be
destroyed/garbage collected with the Java Class object and not have to
do it manually in the Native interface.
Could anyone enlighten me as to how I could do this easily ?
In C#, I was able to do it fairly easily by defining "public delegate"
functions and then making them part of a "struct" in C# and making an
object of that struct in the C# class. Then I could directly access
the members of the struct in C.
But I am not a Java programmer as such, and am having difficulty in
getting it to work in this way.
Thanks and regards,
Vikas