Package com.mapr.fs

Class ShimLoader

java.lang.Object
com.mapr.fs.ShimLoader

public class ShimLoader extends Object
  • Constructor Details

    • ShimLoader

      public ShimLoader()
  • Method Details

    • 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 String getLibraryVersion(Class<?> clazz)
    • main

      public static void main(String[] args)