> -Global variables
I doubt global variables inside the C app can be accessed from JNI native methods.
> -Primitives passed as arguments
Sure, but there is an whole API in C I wan't to make available in Java.
> -Primitives as attributes in a class
Explain? Attributes in class?
> -C/C++ pointers passed as arguments or as class
> attributes using a java long to hold it.
Yes, this is probably the way!
> -Function callbacks.
Explain?
Application layout:
C application <-> [ invoked JVM with Java class ] <-> JNI native library
I wan't to share native info between:
C application <-> JNI native library
>> -Global variables
>
>I doubt global variables inside the C app can be >accessed from JNI native methods.
Whoops! Correct.
>> -Primitives passed as arguments
>
>Sure, but there is an whole API in C I wan't to make
>available in Java.
>
>> -Primitives as attributes in a class
>
>Explain? Attributes in class?
Basically the same as the previous one. So probably no more useful.
>> -C/C++ pointers passed as arguments or as class
>> attributes using a java long to hold it.
>
>Yes, this is probably the way!
You will probably find this is best.
> -Function callbacks.
Presumably you control the code base for both sides of this. A JNI shared library can have normal shared library method calls in it. So use normal shared library protocols to access it. (I haven't tried it so there might be some interesting problems with initially resolving the thunks or there might not.)
You can't use C pointers, at least under Windows, since the C app. and the JNI-invoked DLL are separate processes and hence have separate memory spaces. You can send messages that pass primitives or use the WM_COPYMEMORY message to send objects. You can also use DDE or COM although they may be too "heavyweight".
Regards.
>You can't use C pointers, at least under Windows, since the C app. and the JNI-invoked DLL are separate processes...
uh? No, that isn't correct.
Java and the dlls it loads( or any application that loads dlls) are not seperate processes.
And pointers can be used. I have certainly done so in the past.