2009/8/19 geelpheels <[email protected]>

>
> After browsing the source code of felix, there's one point I cannot
> understand.
> OSGi r4 supports loading native libraries, even the MANIFEST.MF has an
> option:Bundle-NativeCode.
> But in the felix framework project's source code, I cannot find any code
> about automatically loading the native library using this
> "Bundle-NativeCode" option.
> Is this a bug of felix framework or just my misunderstanding of OSGi r4?
> Can anyone tell me?


the native libraries aren't automatically loaded when the bundle starts -
instead it's done on-demand
when a Java class uses System.loadLibrary(), typically inside a static
initialization block in the class

this then calls findLibrary() on the classloader that loaded the class, like
Felix's ModuleClassLoader:


http://svn.apache.org/repos/asf/felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java

which is a custom classloader whose "findLibrary" method delegates to the
respective native library
in the bundle cache according to the bundle involved, the OS, and the
Bundle-NativeCode headers

HTH

--
> View this message in context:
> http://www.nabble.com/Bundle-NativeCode-in-Felix-framework-tp25039905p25039905.html
> Sent from the Apache Felix - Dev mailing list archive at Nabble.com.
>

-- 
Cheers, Stuart

Reply via email to