dcsimg
JNI and multiples library instances (dll, so, etc)
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Luciano_M
Posted On:   Thursday, April 5, 2007 03:33 PM

Usually we load the native library (dll, so, etc) using a static statement, which maps only one instance of library to multiples instances of the class.


How to have one-to-one relation ? Each class instance with its own library instance ?


Does somebody know ?


Regards.

Re: JNI and multiples library instances (dll, so, etc)

Posted By:   shiladitya_sircar  
Posted On:   Tuesday, June 26, 2007 11:31 AM


What this would mean is loading shared/dynamic libraries more than once. It is not possible, to load libraries more than once. The Java class loader that loaded the Java class will only and only once load a system library. Also its not possible to unload a system library once loaded, unless the the class loader that loaded the class goes out of scope or gets garbage collected.




However, you can hack in your own class loader that loads your classes which loads the system library. This way your class laoder can create as many instance of (multipletons) as you want and you can load libs that way. But its a bad idea. There was a reason why Sun choose not to allow this feature.


Why do you need this one to one mapping ? There are other ways to solve class and lib loading problems.



cheers
-ssircar
About | Sitemap | Contact