Foobyto
Foobyto

Reputation: 109

JNI, load 2 times the same dll (differents name), how to choose which one to use?

I'm working with jni on a c++ dll: "sharedMemLib.dll"

My java app correctly loads these dlls twice: sharedMemLib.dll and sharedMemLib2.dll

I'd like to associate a specific dll to an instance of a class, for example, one instance of JNIInterface will access sharedMemLib.dll and another instance of JNIInterface will acesss sharedMemLib2.dll.

The 2 dll have the same functions, any ideas how I could choose wich one to access?

Upvotes: 1

Views: 699

Answers (1)

Java42
Java42

Reputation: 7706

If the entry point names are the same in both DLLs, forget about it. Even if you try to run 2 JVMs under the same OS, I don't think its going to work. You need two different package names ( or two machines ). I did some testing and on my system, the 1st DLL loaded is the one that is used. Now, if you are using callbacks from JNI into Java, the callbacks will be directed to one instance over another because of that 2nd param ( type jobject ) on the call.

Upvotes: 1

Related Questions