Package com.mapr.fs

Class ShimLoader


  • public class ShimLoader
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ShimLoader()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getLibraryVersion​(java.lang.Class<?> clazz)  
      static boolean isNativeLibraryLoaded()  
      static void load()
      Load native library and its JNI native implementation using the root class loader.
      static void main​(java.lang.String[] args)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShimLoader

        public ShimLoader()
    • Method Detail

      • isNativeLibraryLoaded

        public static boolean isNativeLibraryLoaded()
      • load

        public static void load()
        Load native library and its JNI native implementation using the root class loader. This hack is for avoiding the JNI multi-loading issue when the same JNI library is loaded by different class loaders. In order to load native code in the root class loader, this method first inject LibraryLoader class into the root class loader, because System.load(String) method uses the class loader of the caller class when loading native libraries.
         (root class loader) -> [com.mapr.fs.jni.*]  (injected by this method)
            |
            |
         (child class loader) -> Sees the above classes loaded by the root class loader.
           Then creates MapRFileSystem implementation.
         
         (root class loader) -> [ShimLoader, MapRClient, etc]  -> native code is loaded by once in this class loader
           |   \
           |    (child2 class loader)
         (child1 class loader)
        
         child1 and child2 share the same com.mapr.fs.jni.* code loaded by the root class loader.
         
        Note that Java's class loader first delegates the class lookup to its parent class loader. So once com.mapr.fs.jni.* is loaded by the root class loader, no child class loader initialize these classes again.
      • getLibraryVersion

        public static java.lang.String getLibraryVersion​(java.lang.Class<?> clazz)
      • main

        public static void main​(java.lang.String[] args)