Class StubLoader


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

      • VERSION_MAJOR

        public static final int VERSION_MAJOR
      • VERSION_MINOR

        public static final int VERSION_MINOR
      • versionClassName

        private static final java.lang.String versionClassName
        See Also:
        Constant Field Values
      • LOCALE

        private static final java.util.Locale LOCALE
      • bootPropertyFilename

        private static final java.lang.String bootPropertyFilename
        See Also:
        Constant Field Values
      • bootLibraryPropertyName

        private static final java.lang.String bootLibraryPropertyName
        See Also:
        Constant Field Values
      • stubLibraryName

        private static final java.lang.String stubLibraryName
      • TMPDIR_ENV

        private static final java.lang.String TMPDIR_ENV
      • TMPDIR

        private static final java.lang.String TMPDIR
      • TMPDIR_RECOMMENDATION

        private static final java.lang.String TMPDIR_RECOMMENDATION
      • TMPDIR_WRITE_ERROR

        public static final java.lang.String TMPDIR_WRITE_ERROR
      • TMPDIR_EXEC_ERROR

        public static final java.lang.String TMPDIR_EXEC_ERROR
      • failureCause

        private static volatile java.lang.Throwable failureCause
      • loaded

        private static volatile boolean loaded
      • jffiExtractDir

        private static final java.io.File jffiExtractDir
      • jffiExtractName

        private static final java.lang.String jffiExtractName
      • JFFI_EXTRACT_DIR

        private static final java.lang.String JFFI_EXTRACT_DIR
        See Also:
        Constant Field Values
      • JFFI_EXTRACT_NAME

        private static final java.lang.String JFFI_EXTRACT_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • StubLoader

        public StubLoader()
    • Method Detail

      • isLoaded

        public static final boolean isLoaded()
      • getFailureCause

        public static final java.lang.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.
      • getStubLibraryName

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

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

        private static java.lang.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 java.lang.String getBootPath()
      • getAlternateLibraryPath

        private static java.lang.String getAlternateLibraryPath​(java.lang.String path)
      • loadFromBootPath

        private static boolean loadFromBootPath​(java.lang.String libName,
                                                java.lang.String bootPath,
                                                java.util.Collection<java.lang.Throwable> errors)
      • dlExtension

        static java.lang.String dlExtension()
      • loadFromJar

        private static void loadFromJar​(java.io.File tmpDirFile)
                                 throws java.io.IOException,
                                        java.lang.LinkageError
        Throws:
        java.io.IOException
        java.lang.LinkageError
      • unpackLibrary

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

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

        private static java.lang.SecurityException sizeMismatchError​(java.io.File dstFile,
                                                                     int sourceSize,
                                                                     int targetSize)
      • digestMismatchError

        private static java.lang.SecurityException digestMismatchError​(java.io.File dstFile)
      • calculateExtractPath

        static java.io.File calculateExtractPath​(java.io.File tmpDirFile,
                                                 java.lang.String jffiExtractName)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • calculateExtractPath

        static java.io.File calculateExtractPath​(java.io.File tmpDirFile)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • tempReadonlyError

        private static java.io.IOException tempReadonlyError​(java.io.IOException ioe)
      • tempLoadError

        private static java.lang.UnsatisfiedLinkError tempLoadError​(java.lang.UnsatisfiedLinkError ule)
      • getStubLibraryStream

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

        private static java.io.InputStream getResourceAsStream​(java.lang.String resourceName)
      • getVersionField

        private static int getVersionField​(java.lang.String name)