Class StubLoader

java.lang.Object
com.kenai.jffi.internal.StubLoader

public class StubLoader extends Object
Loads the native stub library. This is intended to only ever be called reflectively, so it cannot access other jffi classes.
  • Field Details

    • VERSION_MAJOR

      public static final int VERSION_MAJOR
    • VERSION_MINOR

      public static final int VERSION_MINOR
    • versionClassName

      private static final String versionClassName
      See Also:
    • LOCALE

      private static final Locale LOCALE
    • bootPropertyFilename

      private static final String bootPropertyFilename
      See Also:
    • bootLibraryPropertyName

      private static final String bootLibraryPropertyName
      See Also:
    • stubLibraryName

      private static final String stubLibraryName
    • TMPDIR_ENV

      private static final String TMPDIR_ENV
    • TMPDIR

      private static final String TMPDIR
    • TMPDIR_RECOMMENDATION

      private static final String TMPDIR_RECOMMENDATION
    • TMPDIR_WRITE_ERROR

      public static final String TMPDIR_WRITE_ERROR
    • TMPDIR_EXEC_ERROR

      public static final String TMPDIR_EXEC_ERROR
    • os

      private static volatile StubLoader.OS os
    • cpu

      private static volatile StubLoader.CPU cpu
    • failureCause

      private static volatile Throwable failureCause
    • loaded

      private static volatile boolean loaded
    • jffiExtractDir

      private static final File jffiExtractDir
    • jffiExtractName

      private static final String jffiExtractName
    • JFFI_EXTRACT_DIR

      private static final String JFFI_EXTRACT_DIR
      See Also:
    • JFFI_EXTRACT_NAME

      private static final String JFFI_EXTRACT_NAME
      See Also:
  • Constructor Details

    • StubLoader

      public StubLoader()
  • Method Details

    • isLoaded

      public static final boolean isLoaded()
    • getFailureCause

      public static final Throwable getFailureCause()
    • determineOS

      private static StubLoader.OS determineOS()
      Determines the operating system jffi is running on
      Returns:
      An member of the OS enum.
    • determineCPU

      private static StubLoader.CPU determineCPU()
      Determines the CPU architecture the JVM is running on. This normalizes all the variations that are equivalent (e.g. i386, x86, i86pc) into a common cpu type.
      Returns:
      A member of the CPU enum.
    • getCPU

      public static StubLoader.CPU getCPU()
    • getOS

      public static StubLoader.OS getOS()
    • getStubLibraryName

      private static String getStubLibraryName()
      Gets the name of the stub library.
      Returns:
      The name of the stub library as a String
    • getPlatformName

      public static String getPlatformName()
      Gets the name of this Platform.
      Returns:
      The name of this platform.
    • getStubLibraryPath

      private static String getStubLibraryPath()
      Gets the path within the jar file of the stub native library.
      Returns:
      The path of the jar file.
    • load

      static void load()
      Loads the stub library
    • getBootPath

      private static String getBootPath()
    • getAlternateLibraryPath

      private static String getAlternateLibraryPath(String path)
    • loadFromBootPath

      private static boolean loadFromBootPath(String libName, String bootPath, Collection<Throwable> errors)
    • dlExtension

      static String dlExtension()
    • loadFromJar

      private static void loadFromJar(File tmpDirFile) throws IOException, LinkageError
      Throws:
      IOException
      LinkageError
    • unpackLibrary

      private static void unpackLibrary(File dstFile, InputStream sourceIS) throws IOException
      Throws:
      IOException
    • verifyExistingLibrary

      private static void verifyExistingLibrary(File dstFile, InputStream sourceIS) throws IOException
      Throws:
      IOException
    • sizeMismatchError

      private static SecurityException sizeMismatchError(File dstFile, int sourceSize, int targetSize)
    • digestMismatchError

      private static SecurityException digestMismatchError(File dstFile)
    • calculateExtractPath

      static File calculateExtractPath(File tmpDirFile, String jffiExtractName) throws IOException
      Throws:
      IOException
    • calculateExtractPath

      static File calculateExtractPath(File tmpDirFile) throws IOException
      Throws:
      IOException
    • tempReadonlyError

      private static IOException tempReadonlyError(IOException ioe)
    • tempLoadError

      private static UnsatisfiedLinkError tempLoadError(UnsatisfiedLinkError ule)
    • getStubLibraryStream

      private static InputStream getStubLibraryStream()
      Gets an InputStream representing the stub library image stored in the jar file.
      Returns:
      A new InputStream
    • getResourceAsStream

      private static InputStream getResourceAsStream(String resourceName)
    • getVersionField

      private static int getVersionField(String name)