Package com.kenai.jffi.internal
Class StubLoader
- java.lang.Object
-
- com.kenai.jffi.internal.StubLoader
-
public class StubLoader extends java.lang.ObjectLoads the native stub library. This is intended to only ever be called reflectively, so it cannot access other jffi classes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStubLoader.CPUThe common names of cpu architectures.static classStubLoader.OS
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringbootLibraryPropertyNameprivate static java.lang.StringbootPropertyFilenameprivate static StubLoader.CPUcpuprivate static java.lang.ThrowablefailureCauseprivate static java.lang.StringJFFI_EXTRACT_DIRprivate static java.lang.StringJFFI_EXTRACT_NAMEprivate static java.io.FilejffiExtractDirprivate static java.lang.StringjffiExtractNameprivate static booleanloadedprivate static java.util.LocaleLOCALEprivate static StubLoader.OSosprivate static java.lang.StringstubLibraryNameprivate static java.lang.StringTMPDIRprivate static java.lang.StringTMPDIR_ENVstatic java.lang.StringTMPDIR_EXEC_ERRORprivate static java.lang.StringTMPDIR_RECOMMENDATIONstatic java.lang.StringTMPDIR_WRITE_ERRORstatic intVERSION_MAJORstatic intVERSION_MINORprivate static java.lang.StringversionClassName
-
Constructor Summary
Constructors Constructor Description StubLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.io.FilecalculateExtractPath(java.io.File tmpDirFile)(package private) static java.io.FilecalculateExtractPath(java.io.File tmpDirFile, java.lang.String jffiExtractName)private static StubLoader.CPUdetermineCPU()Determines the CPU architecture the JVM is running on.private static StubLoader.OSdetermineOS()Determines the operating system jffi is running onprivate static java.lang.SecurityExceptiondigestMismatchError(java.io.File dstFile)(package private) static java.lang.StringdlExtension()private static java.lang.StringgetAlternateLibraryPath(java.lang.String path)private static java.lang.StringgetBootPath()static StubLoader.CPUgetCPU()static java.lang.ThrowablegetFailureCause()static StubLoader.OSgetOS()static java.lang.StringgetPlatformName()Gets the name of thisPlatform.private static java.io.InputStreamgetResourceAsStream(java.lang.String resourceName)private static java.lang.StringgetStubLibraryName()Gets the name of the stub library.private static java.lang.StringgetStubLibraryPath()Gets the path within the jar file of the stub native library.private static java.io.InputStreamgetStubLibraryStream()Gets anInputStreamrepresenting the stub library image stored in the jar file.private static intgetVersionField(java.lang.String name)static booleanisLoaded()(package private) static voidload()Loads the stub libraryprivate static booleanloadFromBootPath(java.lang.String libName, java.lang.String bootPath, java.util.Collection<java.lang.Throwable> errors)private static voidloadFromJar(java.io.File tmpDirFile)private static java.lang.SecurityExceptionsizeMismatchError(java.io.File dstFile, int sourceSize, int targetSize)private static java.lang.UnsatisfiedLinkErrortempLoadError(java.lang.UnsatisfiedLinkError ule)private static java.io.IOExceptiontempReadonlyError(java.io.IOException ioe)private static voidunpackLibrary(java.io.File dstFile, java.io.InputStream sourceIS)private static voidverifyExistingLibrary(java.io.File dstFile, java.io.InputStream sourceIS)
-
-
-
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
-
os
private static volatile StubLoader.OS os
-
cpu
private static volatile StubLoader.CPU cpu
-
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
-
-
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
OSenum.
-
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
CPUenum.
-
getCPU
public static StubLoader.CPU getCPU()
-
getOS
public static StubLoader.OS getOS()
-
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 thisPlatform.- 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.IOExceptionjava.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 anInputStreamrepresenting 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)
-
-